Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Contructors  RSS feed

 
Gaurav Agarwal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, Contructor can not be overwritten and inherited but do not know why? plz advise. Thanks in advance......
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Agarwal:
Hi all, Contructor can not be overwritten and inherited but do not know why? plz advise. Thanks in advance......


Dear Gaurav,

A constructor is a special method that is automatically run every time an instance of a class is created.

Constructers are meant only for the own class objects. What do you think that you can acheive by overriding the constructer.

If you really want to acheive the functionality of super class then you may call the super(); but what is the use of overriding constructer.

By Default
Constructors are always called downward from the top of the hierarchy


I hope it helps you.

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