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 RMI and what are the services in RMI?

1245


What do you know about seam?

1123


What are the sequence of steps to write pub or sub model kind of application?

2554


What is scalable, portability in the view of J2EE?

2571


If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?

1122


What is the difference between long.class and long.type?

1173


What are the different methods of identifying an object?

1127


Is “abc” a primitive value?

1157


When a thread blocks on i/o?

1168


Why won’t the jvm terminate when I close all the application windows?

1298


Can I run seam outside of jboss as?

1112


What are the purpose of introspection?

1257


How would you reatach detached objects to a session when the same object has already been loaded into the session?

1259


What is the form of storage space in java?

2298


In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?

2711