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
What is RMI and what are the services in RMI?
What do you know about seam?
What are the sequence of steps to write pub or sub model kind of application?
What is scalable, portability in the view of J2EE?
If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?
What is the difference between long.class and long.type?
What are the different methods of identifying an object?
Is “abc” a primitive value?
When a thread blocks on i/o?
Why won’t the jvm terminate when I close all the application windows?
Can I run seam outside of jboss as?
What are the purpose of introspection?
How would you reatach detached objects to a session when the same object has already been loaded into the session?
What is the form of storage space in java?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?