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 we instantiate Interfaces?
What does a void function return?
What is public static void main?
Is break statement can be used as labels in java?
What is Distributed Application and what is its usage?
what is associative array
How to split arraylist elements in java?
What are synchronized methods ?
What is an object-oriented paradigm?
What is the exact difference in between Unicast and Multicast object?
What are the Memory Allocations available in JavaJava?
Is jdk required on each machine to run a java program?