• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problems in Inheritence

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
deepu Bhalotia
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please make it more clearer...

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

Thanks,
Deepak
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the answer is i think b,d, e...

is i m rt ?
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and what about keyword super???
 
deepu Bhalotia
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is

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


Thanks,
Deepak
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic