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 |
Default layout of panel and frame?
What is variable length arguments in java?
What is an example of a boolean?
Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.
I want to store more than 10 objects in a remote server? Which methodology will follow?
how a marker interface gets its functionality and when we implements a marker interface how it got invoked
Explain about assignment statement?
Why do we need wrapper classes?
Mention some interfaces implemented by linked list in java.
How do generics work?
How do I convert a string to an int in java?
Why is it important to initialize a variable?