aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 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 "constructor" Watch "constructor" New topic
Author

constructor

gayatri ganesh
Greenhorn

Joined: Jan 18, 2005
Posts: 28
Hi,
Can someone give an example to explain this question and the answer ?

Suppose that the superclass constructor invocation, "super(argumentListopt);", appears explicitly in a subclass constructor. If a compile-time error is to be avoided then the arguments for the superclass constructor invocation, "super(argumentListopt);", can not refer to which of the following?

a. Static variables declared in this class or any superclass.
b. Instance variables declared in this class or any superclass.
c. Static methods declared in this class or any superclass.
d. Instance methods declared in this class or any superclass.
e. The keyword this.
f. The keyword super

Answer b,d,e,f

Thank You
Liang Anmian
Ranch Hand

Joined: Jun 25, 2004
Posts: 119
Option A is legal. Static variables/methods are not tied to any particular instance of the class, so it is legal to call them in this fashion.

Option B is illegal, because the superclass constructor must complete before you have access to the instance variables/methods of your own class.

Option C is legal. Same reason as option A.

Option D is illegal. Same reason as option B.

Option E is illegal. Same reason as option B. If the superclass constructor has not completed, you will not have access to the "this" reference.

Sorry, but for option F, I don't quite know how to explain. Maybe another kind soul can do it?


Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: constructor