Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

constructor with parameters  RSS feed

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


explain how catch block act as constructor with parameter?
 
Marshal
Posts: 58378
178
  • 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?
 
author
Marshal
Posts: 23438
138
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: 58378
178
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!