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 |
Can you add null to a list java?
Can we overload run() method in java?
explain oops concepts with examples?
29 Answers AbhiBus, Beeline, DELL, HCL, Satyam, TCS, VLS, Wipro,
What carriage return means?
Is java jre still free?
Can we clone singleton class in java?
Can we call a non-static method from inside a static method?
What is navigable map in java?
What is join () in java?
Is vector ordered in java?
why are there separate wait and sleep methods? : Java thread
Explain reverse a linked list recursive java solution?