This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

in simple servlet ,why a constructor has super()?.  RSS feed

 
jacob deiter
Ranch Hand
Posts: 587
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in simple servlet ,why a constructor has super()?.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because, Servlet must need to have default constructor[no-arg constructor]. Container use the default constructor to instantiate the servlet .
 
jacob deiter
Ranch Hand
Posts: 587
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok,then what the super() keyword does???

in some scenariop init method also contains super() ,then what it does here??
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:
in some scenariop init method also contains super() ,then what it does here??


Wrong . init() method doesnt have super() . super() calls the super class default constructor . compilar put the super() at the first statement of the constructor implicitly. you cant call super() from methods . but you can call super class method from your sub class method using super.methodSuper(). so you probably saw the super.init(config); from
public void init(ServletConfig config)

Hope This Helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!