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

What is Yield() method when we r using this ? tell exactly

2 Answers  


Hi buddy, well i got that there is always a default constructor with abstract class. OK. But why not with interface? Thanks in advance.

2 Answers  


What is mean by UML? what is the use? where we are using?

1 Answers   Eka Software,


What is aggregation and composition ?

1 Answers   Fidelity,


Java.util.regex consists of which classes?

0 Answers  


Describe the syntax of multiple inheritance? When do we use such an inheritance?

0 Answers   Fidelity,


What is Gang of four design patterns

0 Answers   Infosys,


What is the difference between the direct buffer and non-direct buffer in java?

0 Answers  


I need to know about complete topic in java's collections i with an examples

1 Answers   TCS,


Differentiate between a constructor and a method? Can we mark constructors final?

0 Answers  


Name the packages in JDK?

2 Answers  


Why arraylist is used in java?

0 Answers  


Categories