answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2012-07-24 16:27:03

Remember that derived classes can access the public and protected members of their base class, but none of the private members. If the member variable in the base class is protected (rather than private), then the derived class can assign it directly. However, this is bad style in OOP as it undermines data-hiding. A protected mutator (set accessor) would be a better option.

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Loading...

Still Have Questions?

Related Questions

Can a double value be assigned to a float value?

No, but a double value can be assigned to a float variable. (You will lose from the precision, obviously.)


What are the difference between private variable and final variable?

A private variable is one that is accessible only to the current class and cannot be accessed by any other class, including the ones that extend from it. A final variable is one that cannot be modified once it is initialized and assigned a value.


What value is assigned to extern variable?

Default initial value of extern integral type variable is zero otherwise null.


What is used as placeholder for an assigned value in a computer memory?

Variable


How do you use define in C?

Just type declare then the variable that you desire to assigned a certain constant value on it. Just type declare then the variable that you desire to assigned a certain constant value on it.


What is an expression with one variable?

3x+2 x is a variable. A variable is a symbol (x, y, etc...) that does not have an assigned value.


What is the definition of constant variable?

The definition of constant variable is a variable whose value cannot be changed once it has been assigned a value for an experiment. It is the variable held steady, or constant, for a specific experiment.


What is the decimal value of the letter u?

None. A letter has no numerical value unless it represents a variable and a value is assigned to it.


Can an int value be assigned to String variable?

In C when assigning an integer variable to String variable a compilation error occurs as Incompatible Type Conversion.So that integers cannot get assigned to String variables.


Difference between preincrementing a variable and postincrementing a variable?

Both increment the value of the variable by one. The difference is the value of the increments expression itself. With preincrement value is taken after incrementing, and with postincrement value is taken before incrementing. Example: Let x have value 5. y = ++x; Both y and x are assigned value 6. Again let x have value 5. y = x++; y is assigned value 5. x is assigned value 6.


How do you assign values to variables?

it depend on the programming language u use. for instance in c, just decalre the variable and equal it to the value it is to take. eg. my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ //for php $my_age=21; /*my_age is the decared variable and 21 is the assigned value*/ for strings (in php)eg. $my_age="none of ur business" /*$my_age is the variable and the string "none of ur business" is the assigned value*/


Which is the default variable storage class type in a function?

Everything is an object, and "typed" based on assignation. Your variable will be given a class when you declare it to be something, and the class will depend on what value you give the variable. It is always an object though, and its class may change if you change its value.


Can an float value be assigned to int variable?

In C a float value can be assigned to an integer variable but an implicit casting occurs when compiler forces a float value to be assigned as an integer. So that the digits after the decimal notation in the float value get loss after assigning a float to an integer.eg:int a=12.356;// Implicit casting occursprintf("%d",a);// when printing a it shows as 12 as an integer


2 plus t7 -1?

And what is the question? - The value of such an expression will depend on the value assigned to the variable, in this case, "t".


What is a transient variable?

Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the val ue of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null


What is the function of default values in java?

Default values are available for any class or instance variable. If you do not specify a value for a class or instance variable the JVM will provide a default value that will ensure that the system does not end up with any unexpected errors because you used a variable that was not initialized. Ex: Public class Test { int I; } In the above class we have just declared an instance variable called 'I' but we haven't associated any value to it. The JVM automatically assigns 0 as the default value to this variable.


Is A value with a decimal portion automatically rounded to a whole number when assigned to an Integer variable?

Yes.


Which qualifier is used to declare read-only variable in java?

A variable declared as final can't be modified, once a value is assigned.


What does open sentence mean?

In math, that refers to an equation which includes a variable. Such an equation may be true, or false, depending on the value assigned to the variable.


Can an int value be assigned to float variable?

Yes, an integer can be assigned as a float value.But it get stored as a float value, that is an implicit type conversion occurs during compilation.Smaller data types are convertible to larger data types.eg:float b=12;// an integer constant is assigned to a float variableprintf("%f",b);// when printing b it will print as 12.000000


What does a Java Boolean type variable declared but not yet initialized contain when its class is instanciated?

If it is a class or instance variable, it gets the default value of false. If it is a local variable (inside a method), it doesn't have a value until you explicitly set one.


What does instance field mean in Java?

Fields defined without the "static" keyword.Their value is unique to each instance (object) of a class.AnswerInstance variable is a variable declared within the class for which every object of the class has its own value.


What is Difference between class variable and instance variable with example?

Well, at the basic level, class fields, or static fields, as they are called sometimes, belong to the class and not to any particular instance of the class. Class fields can be assigned without instantiation of instance objects of a class. For example: public class ExampleClass { public static String classField = ""; public String instanceField = ""; } I can assign a value to classField just like that: ExampleClass.classField = "new value"; Instance fields, on the other hand, belong to a particular instance of the class. Thus, to assign an instance field a value, you have to first instantiate an object of the class just like that: ExampleClass obj1 = new ExampleClass(); obj1.instanceField = "new value";


How Can a derived class access an integer variable of base class in qt?

The best design strategy would be to provide a protected accessor (getter) that returns the variable either by value or by constant reference. If the derived class needs to mutate the variable, then provide a protected mutator (setter). Only derived classes have protected access to their base classes. However, derivatives can also lower that access to private with respect to their own derivatives, if desired. Even if the variable does not represent a class invariant, it's still best to provide an interface rather than expose an implementation detail outside of the class, whether that exposure is public or protected. In this way the implementation detail may be changed at a future time without affecting any of the consumers of your class (including derivatives), since they will all be using the public or protected interface. So long as that interface remains unchanged, the scope of your internal changes is limited to the class itself, thus you won't break any code that uses your class. If your class already provides a public interface to the variable, then your derived class can obviously make use of that as well. You only need a protected interface when no public interface is provided.


What are the difference between null and undefined in Javascript?

undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value. Also, undefined and nullare two distinct types: undefined is a type itself (undefined) while null is an object