Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

can a static method be overridden

Answer Posted / nisha

/* STATIC METHODS CANT BE OVERRRIDDEN....*/

class Animal {
static void doStuff() {
System.out.print("a ");
}
}

class Dog extends Animal {
static void dostuff() { // it's a redefinition,
// not an override
System.out.print("d ");
}

public static void main(String [] args) {
// Animal [] a = {new Animal(), new Dog(), new Animal()};
// for(int x = 0; x < a.length; x++)
// a[x].doStuff(); // invoke the static method

dostuff();
Animal a=new Dog();
a.doStuff();
}
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you detect a keypress in a jcombobox?

1185


Why are my checkboxes not being set from on to off?

1179


How can I scroll through list of pages like the search results in google?

1009


Do we need to override service() method

1784


Explain how will the struts know which action class to call when you submit a form?

1011


Explain what is synchronization?

1144


Are enterprise beans allowed to use thread.sleep()?

1196


What are the types of scaling?

1139


What is the purpose of the notifyall() method?

1091


Whats new with the stop(), suspend() and resume() methods in jdk 1.2?

1101


what is an isolation level?

2795


Is the session factory thread safe?

1230


How a component can be placed on Windows?

2912


What if the static modifier is removed from the signature of the main method?

1301


What does module-relative mean?

1227