Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

default constructor and init method

 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
container first calls the default constructor and then the init method.

Is it corrent or it is other way around ?

thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how would it call the init method on an instance before it was created using the constructor?
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i am not wrong you are saying that container calls constructor first and create the instanace and then this instance calls the init method.

Please correct me if i am wrong.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. A servlet is the same as any Java Class: you need to create an instance via a constructor before you can call methods on the instance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic