This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Which statement is true for default Constructor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Which statement is true for default Constructor?" Watch "Which statement is true for default Constructor?" New topic
Author

Which statement is true for default Constructor?

Shanel Jacob
Ranch Hand

Joined: Jun 18, 2006
Posts: 112
Which is true?



K&B1.4 page 334 has the following statement.

1) The default constructor is a no-arg constructor with a no-arg call to super().

2) Instance methods and variables are only accessible after the super constructor runs.
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
both are true.
Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
default constructor = no-parameter constructor.

subclasses with "default constructor" will call (compile-time check) "default constructor" of its superclass.

I believe initialisation happens when we create instances, when we call "new".


SCJP 5
Ashwini Ghamandi
Ranch Hand

Joined: Jun 01, 2006
Posts: 74
if there is no other constructor then only default constructor invoked.


SCJP,<br />SCWCD,<br />SCBCD 1.3,<br />SCBCD 5,<br />SCDJWS(In process....)
Shanel Jacob
Ranch Hand

Joined: Jun 18, 2006
Posts: 112
I think what confuses me is "initializes the instance variables".

If it is "new" that "initializes the instance variables", then the 2nd statement would be false.

What do you guys think?
Ivan Rebrov
Ranch Hand

Joined: Jul 09, 2006
Posts: 30
Originally posted by Shanel Jacob:
Which is true?


1) The default constructor invokes the no-parameter constructor of the superclass.

true

2) The default constructor initializes the instance variables declared in the class.

false

----------------------------------


K&B1.4 page 334 has the following statement.

1) The default constructor is a no-arg constructor with a no-arg call to super().

true

2) Instance methods and variables are only accessible after the super constructor runs.

true


SCJP 5.0 - 95%<br />Preparing for SCWCD
Naveen Zed
Ranch Hand

Joined: Aug 11, 2006
Posts: 61
Originally posted by Shanel Jacob:
Which is true?



K&B1.4 page 334 has the following statement.

1) The default constructor is a no-arg constructor with a no-arg call to super().

2) Instance methods and variables are only accessible after the super constructor runs.
prarthana reddy
Ranch Hand

Joined: Jul 24, 2006
Posts: 48
The default constructor initializes the instance variables declared in the class.
Hi,
Once a call to super() by the subclass constructor is placed ,all the instance variables will be initialised to their default values. Only when that superclass constuctor and the subclass constructor calls completes
, the variables are initialised to their given values .
 
GeeCON Prague 2014
 
subject: Which statement is true for default Constructor?