• Post Reply Bookmark Topic Watch Topic
  • New Topic

constructor with parameters  RSS feed

 
bairava surya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


explain how catch block act as constructor with parameter?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bairava surya wrote: . . .
explain how catch block act as constructor with parameter?
What does that question mean?

You have a constructor which does not act as a constructor, because it does not initialise any fields. You have a method which throws an Exception and that Exception is caught. But there is no relationship between the Exception and the constructor.
 
bairava surya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
explain me how super keyword works in this program?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bairava surya wrote:explain me how super keyword works in this program?


The super keyword, as used in your example, in the constructor of the subclass, is choosing which constructor of the superclass to use to initialize the superclass components of the subclass. By default, if you don't have that call, it will use the no-arg (default) constructor of the superclass.

Henry
 
bairava surya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
explain me how the content in the msg(super(msg)) is passed to catch block how it works?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean, “what does super(...); in a constructor mean?“

Start with this part of the Java® Tutorials and this section.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!