• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

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.
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic