• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

What is going on in this code

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 13
Mac Mac OS X Mac PPC
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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().
 
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic