• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in simple servlet ,why a constructor has super()?.
 
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: 588
  • 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!