Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Default layout of panel and frame?

3 Answers  


What is variable length arguments in java?

0 Answers  


What is an example of a boolean?

0 Answers  


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

0 Answers   Fidelity,


I want to store more than 10 objects in a remote server? Which methodology will follow?

0 Answers  


how a marker interface gets its functionality and when we implements a marker interface how it got invoked

3 Answers   Mind Tree,


Explain about assignment statement?

0 Answers  


Why do we need wrapper classes?

0 Answers  


Mention some interfaces implemented by linked list in java.

0 Answers  


How do generics work?

0 Answers  


How do I convert a string to an int in java?

0 Answers  


Why is it important to initialize a variable?

0 Answers  


Categories