File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

constructor

 
gayatri ganesh
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic