• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

super(10)

 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//code:-

package spital;

public class Mudchute extends Spital{
public static void main(String argv[]){

Mudchute ms = new Mudchute();
ms.go();
}
public Mudchute(){
super(10);
}
public void go(){
island();

}
public void island(){
System.out.println("island");
}

}

THE answer is "Output of 10 followed by island"
I'm fine on 'island'...the '10' needs clarification.

http://java.sun.com/docs/books/tutorial/java/javaOO/methodbody.html
states:
"super
If your method hides one of its superclass's member variables, your method can refer to the hidden variable through the use of the super keyword. Similarly, if your method overrides one of its superclass's methods, your method can invoke the overridden method through the use of the super keyword. "
afaics...super(10); is neither hiding a variable or a method in the super class [ or is it ? ]
TIA
 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can't answer your question unless you include the code for the class Spital.
 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Louie van Bommel:
We can't answer your question unless you include the code for the class Spital.



Oh ya, that's Marcus' tutorial question. I'm pretty sure it's an error in the question.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Louie van Bommel:
I'm pretty sure it's an error in the question.

Yeah, we would need to know what the int-argument constructor for Spital looks like. Evidentially, it's supposed to be something like this...

Ref: http://www.jchq.net/certkey/0401certkey.htm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic