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?
Answers were Sorted based on User's Feedback
Answer / 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 |
What is the difference between the boolean & operator and the && operator in java programming?
Name two subclasses of the TextComponent class?
What are the names of Component subclasses that support painting?
Which java collection does not allow null?
How do you use parseint in java?
Can a class have an interface?
What is assembly language?
Is string is a class in java?
What state is a thread in when it is executing?
Is string a class in java?
What is the importance of hashcode() and equals() methods?
How does remove work in java?