• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is going on in this code

 
Vikas J Yadav
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Added code tags - see UseCodeTags for details]

Produced Output as
sub static
Superclass arg
Subclass no-arg

I have written a code to call SuperClass satic method; I know that SuperClass static methods cannot be overriden but what happens with this line super(method()); of code
 
Jack McLaren
Greenhorn
Posts: 13
Mac Mac OS X Mac PPC
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vikas J Yadav wrote:

what happens with this line super(method()); of code


It will call super class constructor with int parameter.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you call a static method without qualification it's going to look in the current class. If you want to call the superclass version here you need to qualify it: SuperClass.method().
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please use code tags if you want to post any code snippet.
and in your code method() has a return type of int ,so super(method()) passes 5 value to superclass constructor.

Regards
Gajendra
 
Vikas J Yadav
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thanks all for quick reply. It solved my doubt

Thanks Gajendra for your suggesion. I will make sure that i wll post the code with proper format

-Vikas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic