• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance Output

 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



and my testing class

i was expecting the out put as
in Employee class
in salesManager class
in Ceo constructor
but the out put is

in Employee class
in Employee class
in salesManager class
in Ceo constructor
why the constructor of employee is called twice
 
Matthew Brown
Bartender
Posts: 4565
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you're creating two of them. One Employee on line 10, and one CEO on line 11 (which leads to the base-class constructors being called). Did you forget about the firsty one?
 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohhh ya extremely sorry i forgot about the frist line
thanku for your time.... i have just practising the inheritance...
i wanted to know that about the super keyword
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic