• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many objects are created ?

 
al nik
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abstract class AbstractClass {}
interface MyInterface { }
class Parent extends AbstractClass implements MyInterface { }
class Child extends Parent {}


How many objects are created when I call
Child child = new Child();

 
Kishore Kumar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only two objects are created. One is Parent object and another is Child object.
 
David Coppens
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure? I think you only create 1 object here.
Can anybody please confirm the answer given above?
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating an object of a class causes it's super class Constructor to be invoked but that doesn't create extra object.
 
al nik
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating an object of a class causes it's super class Constructor to be invoked but that doesn't create extra object.


OK! This's what I thought! Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic