Click here to Skip to main content
14,975,411 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am having a class A .suppose the class B extends A .

when i am creating the instance of B ..two objects are created one for A and other for this two objects are related specifying this A object is related to only this B object....
class A{}

class B extends A{

  public static void main(String[] args){
      B b = new B(); 

here two objects are created one for the super class A and for the subclass B...

how the specific A object related to this b.......
Updated 16-Aug-11 22:53pm

Both constructors are called, but only one object is being created and that is of type B. Read the fundamentals of OOP.
See here[^] for more details.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900