aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problems in Inheritence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problems in Inheritence" Watch "Problems in Inheritence" New topic
Author

Problems in Inheritence

deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
This question has been given in http://www.danchisholm.net/july21/mybook/chapter11/exam1ans.html

Question 2
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.


Can anybody explain it with an Example....

Thanks,
Deepak

(Hopefully fixed the link...)
[ May 10, 2005: Message edited by: Barry Gaunt ]
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
A member variable or a method or reference of "this" cannot be passed to the super class constructor because all these things gets initilized only after all the calls to the constructors gets completed.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
can you please make it more clearer...

This question is teasing me for a long time...

Thanks,
Deepak
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Deepu,


In the above code when the child class constructor is invoked it calls the superclass constructor explicitly and passing a member variable of the current class as a parameter to the constructor. The members gets initilized only after the call to the constructor is over, but if you see in the code the call to the constructor is not completed but the member variable is accessed.
HTH.
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
the answer is i think b,d, e...

is i m rt ?


Thanks and Regards, Amit Taneja
Soni Prasad
Ranch Hand

Joined: Mar 09, 2005
Posts: 97
and what about keyword super???


SCJP 1.4, SCBCD 1.3
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
Answer is

1. B
2. D
3. E
4. F


Thanks,
Deepak
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problems in Inheritence