Question

Context of my question: I am reading C#. Trying to understand Static keyword. I understand that...

Context of my question:

I am reading C#.
Trying to understand Static keyword.
I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class object references.
I will take an example here.

public class BluePrint
{
   public static string BluePrintCreatorName;
}
If I need to know the BluePrintCreator's Name, I can call

BluePrint.BluePrintCreatorName;
But if a house that is created from the blueprint wants to know the BluePrintCreator's Name, it does not have access.

BluePrint NewHouse = new BluePrint();
NewHouse.BluePrintCreatorName; //This is not accessible
Compiler error says:

Member 'AccessModifier.BluePrint.BluePrintCreatorName' cannot be accessed with an instance reference; qualify it with a type name instead
I understand this is the way it works. But I want to know the basic concept to why Static keyword was required at all?

What will go wrong if a class object reference would have access to the static member?

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Context of my question: I am reading C#. Trying to understand Static keyword. I understand that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer...

    1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); a.add(new Integer(7)); System.out.println(b.size()); A)1 B)2 C)3 D)4 E)5 2. Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code:     Person p1, p2, p3;     int m1, m2, m3;     p1 = new Person();     m1 = p1.getMoney();     // assignment 1...

  • I am trying to understand how to manipulate the Gregorian Calendar so that I can convert...

    I am trying to understand how to manipulate the Gregorian Calendar so that I can convert my answer into a string format. What I'm hoping to do is to do is return string to a different file to add to a string in separate file (Object-oriented exercise between files), but once I can convert this into a string I can convert this file on my own. I added the System.out.println() to show what the results should look like. In other...

  • Below I have my 3 files. I am trying to make a dog array that aggerates...

    Below I have my 3 files. I am trying to make a dog array that aggerates with the human array. I want the users to be able to name the dogs and display the dog array but it isn't working. //Main File import java.util.*; import java.util.Scanner; public class Main {    public static void main(String[] args)    {    System.out.print("There are 5 humans.\n");    array();       }    public static String[] array()    {       //Let the user...

  • I am trying to understand the following code I found in a website so that I...

    I am trying to understand the following code I found in a website so that I can use it for a project that evaluates boolean expressions. The code is below but I think it is in java because I do not understand it. Can you help me describe what it is doing in c++ so that I can understand it better? The link to the code is here: https://stackoverflow.com/questions/16762057/algorithm-to-evaluate-value-of-boolean-expression The code is below: public static boolean evaluateBool(String s) { Stack<Object>...

  • i created a two dimensional matrix class which holds my object complex number. I am trying...

    i created a two dimensional matrix class which holds my object complex number. I am trying to overload the parenthesis () so that I can access and modify the value at specified location of the matrix. say matrix[a][b] = 5; and my_vals is a private member of the matrix class. What is the problem with my code //constructor & inlitilize dynamic array matrix::matrix(int rows, int cols) { complex** m_vals = new complex * [rows]; for (int i = 0; i...

  • My Grades- WIT Question Completion Status: QUESTION 8 A class may have Ono, only one default...

    My Grades- WIT Question Completion Status: QUESTION 8 A class may have Ono, only one default constructor(s) and destructor only one, more than one more than one, more than one only one, only one more than one, only one QUESTION9 Public members of a dlass object can be accessed from outside the class by using the O get function. extraction operator dot operator. O member access operator. class name. QUESTION 10 if Square is the name of a dlass, which...

  • Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

    Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...

  • pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the...

    pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the last assignment by providing the following additional features: (The additional features are listed in bold below) Class Statistics In the class Statistics, create the following static methods (in addition to the instance methods already provided). • A public static method for computing sorted data. • A public static method for computing min value. • A public static method for computing max value. • A...

  • Java please answer A to I please dont type the answer on paper please use the...

    Java please answer A to I please dont type the answer on paper please use the computer A.   Explain why alpha cannot be accessed by other members of its class. B.   In the program, how can you determine the type of access modifier? C.   Describe the differences and similarities of beta and gamma in program, within the context of access specifiers and class member accessibility. D.   Explain how objects, a and b, are passed to the method. E.    Why...

  •    i am taking a c++ class. please answer these four question detailedly. thank you in...

       i am taking a c++ class. please answer these four question detailedly. thank you in advance. Know how to do the tracing problems with classes, aka BaskinRobbins type problem What are some of the benefits to Object Oriented programming? What do the concepts of object reusability and data hiding mean? How do you access a data member of a structure/class? How do you pass an array to a function?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT