• 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

static methods

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i have doubt in static methods, as static method can't be overriden,how is it possible to access the behaviour of super class in base class.i have code
class Animal
{
static void dostuff(){
System.out.println("aaaaaa");
}
}

class Dog extends Animal
{
public static void main(String[] args){
//Animal a=new Animal();
//a.dostuff();
//Animal a1=new Dog();
//a1.dostuff();
Dog d=new Dog();
d.dostuff();
}
}

though i now static methods are not overriden, as they method and can be accessed in base class through hidding ,but here i not used the static method then i able to access it .if i am wrong please guide me.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sub-class(within the same package) can access all the members of super class whether static/non-static unless marked private.
reply
    Bookmark Topic Watch Topic
  • New Topic