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 do you understand by the term wrapper classes?
what is the output??????? public class multireturn { public(int assign x ( int x) { if(4==x) { return 7; } else if (7=x+3) { return 6; } return 5; } }
Difference between class#getinstance() and new operator ?
What is the purpose of lambda expressions?
Which is easier netbeans or eclipse?
Name the types of mouse event listeners ?
What is a buffer in java?
What is the protocol is used in type4 driver?
how many ways we can serialize the java object?
How objects of a class are created if no constructor is defined in the class?
How many types of flags are there?
what is difference between Exception and Error?