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 / nilesh more

Finally, remember that static methods can't be overridden!
This doesn't mean they can't be redefined in a subclass, but
redefining and overriding aren't the same thing.
Let's take a look at an example of a redefined (remember,
not overridden), staticmethod:

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
}
}


Running this code produces the output:
a a a







The above written material is from kathe Siera which clearly
says that "Static methods can't be overridden."
But you can only redefine them which is not as overriding.
For any further perfect explanation please refer kathe Ciera
book

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between the string and stringbuffer classes?

1162


How to deploy Jar, War files in J2EE?

2735


What is table mutation and how do you avoid it?

2527


How messaging services are done, before release of JMS?

2224


Why are some of the class and element names counter-intuitive?

1218


How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!

3061


What is the difference between session and entity beans?

1175


What is a sessionfactory? Is it a thread-safe object?

1265


What is difference between object state and behavior?

1154


What state does a thread enter when it terminates its processing?

1129


What’s jboss cache in short?

1187


Is the ternary operator written x : y ? Z or x ? Y : z ?

1161


What are the pros and cons of detached objects?

1039


what is the use of State Factories?

2448


What class is used to create Server side object ?

2315