• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can parent class constructor be invoked using this operator?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements are true?
[a] Parent class constructors are not inherited to subclass
[b] Constructors can be overloaded but not overridden
[c] A parent class constructor can be invoked using this operator
[d] Any method may contain a call to this or super
The ans. given to above code is a,b and c where as i think c option is vague becoz if parent class is meant be super class then its constructor can be invoked by using super not this.
Please clarify
Thanks
Jyotsna
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually you can do this:
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to execute the following code in JBuilder

when I tried to compile it I got the following error

"Java0601.java": Error #: 479 : illegal qualifier; class anshul.JTestA is not an inner class at line 26, column 8

thanks

------------------
AM
anshulmohan@rediffmail.com
[This message has been edited by Anshul Manisha (edited June 15, 2001).]
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anshul,
Something is wrong with your JBuilder ...
If you are trying to argue with Tom then give it up. He is correct. Try the following code to prove it (try it outside of JBuilder).

Regards,
Manfred.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiled clean in version 1.2. Error in version 1.3
 
Anshul Manisha
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what is the final conclusion? Tom did you also get the same compilation error as the one I got with JBuilder4. Incidently the JVM used by JBuilder is 1.3.0-c
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I got the same error when I compiled using 1.3. The final verdict? I would say that this.super is an odd construct anyway and since it doesn't work in the current release version of the JDK that this.super is an illegal construct. I haven't had a chance to see if the JLS says anything about it.
 
Jyotsna Umesh
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas Paul:
Yes, I got the same error when I compiled using 1.3. The final verdict? I would say that this.super is an odd construct anyway and since it doesn't work in the current release version of the JDK that this.super is an illegal construct. I haven't had a chance to see if the JLS says anything about it.


Thanks Thomas, so in this circumstances should we select the option c also?
Jyotsna
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if it has to do with 1.2 or 1.3, JBuilder3 gives me a compler error for either 1.2 or 1.3 when I use this.super(). It works fine when I use just super() .
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jyotsna Umesh:
Thanks Thomas, so in this circumstances should we select the option c also?

I have a feeling you won't see anything like that on the certification exam but the answer would really depend on what (if anything) the JLS says.

------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
This tiny ad is suggesting that maybe she should go play in traffic.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic