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 java in layman terms?
Why java does not support pointers?
What is pass by value?
Is null or empty java?
What do u mean by variable?
What is type safety in java?
Why java does not supports multiple inheritance?
Explain the significance of listiterator.
What are latest features introduced with java 8?
Can Anybody tell the diff b/w jdk1.6 and latest version.
Can we overload run() method in java?
What are Font and FontMetrics classes?