Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Verification of constructor calling

 
Glenn Gould
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Verification of constructor calling
1) From within the same class
When you are within the same class, one constructor can call another constructor using the "this" keyword


2) Within a class hierarchy
When there is an inheritance hierarchy, the constructor of the subclass can call the constructor of the superclass using the "super" keyword


Please confirm.
 
Mala Gupta
Author
Ranch Hand
Posts: 294
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glenn,

Verification of constructor calling
1) From within the same class
When you are within the same class, one constructor can call another constructor using the "this" keyword

2) Within a class hierarchy
When there is an inheritance hierarchy, the constructor of the subclass can call the constructor of the superclass using the "super" keyword
Please confirm.



Both of your statements are correct - as already confirmed by the code output.

With respect,
Mala



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic