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 |
Define an applet in java?
What classes of exceptions may be thrown by a throw statement?
Does a function need a return?
What is "this" keyword in java? Explain
Explain aggregation in java?
What is the diffrence between inner class and nested class?
Define an enumeration?
difference between arraylist and linkedlist otherthan performance
What is not object oriented programming?
How to create a fecelet view?
In Java, what are this() and super(), and where are you required to use them?
what difference between throw and throws in exception handling.