In Inheritance if we are implementing Multi level inheritance
and all class having same name of variable and now i want to
access each class variable and how it is possible?
Answer Posted / megha
IF ClassC extends ClassB and ClassB extends ClassA
All Classes having "public int a " with different values,
then
ClassA objA = new ClassA();
ClassB objAB = new ClassB();
ClassC objAC = new ClassC();
System.out.println(objA.a);
System.out.println(objAB.a);
System.out.println(objAC.a);
will show each class variable individually
****************************O R *******************
make a method to return superclass variable using "super.a"
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
Is java a utf 8 string?
What is the size of integer?
What is an off by one error in java?
Why java is secure? Explain.
Why is string buffer better than string ?
What does you mean in math?
What is use of static method?
Explain about narrowing conversion in java?
Name container classes in java programming?
What is the range of the short type?
What is constructor and its types?
What is boolean flag in java?
How many types of parsers are there?
What do you understand by java?