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



In Inheritance if we are implementing Multi level inheritance and all class having same name of va..

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

In Inheritance if we are implementing Multi level inheritance and all class having same name of va..

Answer / sabari

We cannot use the same name for all classes.

Is This Answer Correct ?    7 Yes 11 No

Post New Answer

More Core Java Interview Questions

where exactly collections are usefull in realtime

2 Answers  


What is the structure of java?

0 Answers  


What is a method header?

0 Answers  


What is the difference between the final method and abstract method?

0 Answers  


What is the maximum size of hashmap in java?

0 Answers  






How many bits is a char?

0 Answers  


What is append function?

0 Answers  


How do u pass data from one jsp to another jsp?

3 Answers   Fidelity,


What's the base class of all exception classes?

0 Answers  


What are jee technologies?

0 Answers  


What is the difference between Trusted and Untrusted Applet ?

2 Answers   IBM,


What is meant by Servelet? What are the parameters of service method?

2 Answers  


Categories