Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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: 291
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



 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic