Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An applet constructor(Urgent)

 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is it not necessary to define constructors in Applet?
Thanks,
Angela
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't necessary to define constructors anywhere.
If you haven't defined any constructors, the compiler creates one for you that takes no arguments.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you're more curious about why you don't have to explicitly instantiate an applet when you might otherwise if it were an application (as perhaps one of the first commands in the main method).
The applet viewer or web browser does this for you by calling the no arg constructor (which the compiler may have created for you if you haven't defined any constructors).
Anything making sense?
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
Perhaps you're more curious about why you don't have to explicitly instantiate an applet when you might otherwise if it were an application (as perhaps one of the first commands in the main method).
Anything making sense?

You mean that Parent Applet class has default constructor which will automatically called by web browser. Am I right???
Thanks,
Angela
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not exactly (or not directly at least). I mean that in the applet class you create, if you don't specify any constructors, the compiler creates a default no-argument constructor and this is invoked by the web browser. Because your applet extends the class Applet, the first thing that this default no-argument constructor does is invoke the parent class's (Applet's) default no-arguement constructor.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic