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
Why use a datasource when you can directly specify a connection details?
Why use a datasource when you can directly specify a connection details? (in a J2EE application)
What is the RMI and Socket?
Explain about local interfaces.
Why are component architectures useful?
whats is statement and procedure
Difference between hashmap and hashtable?
Explain what is orm?
when A client sent a request to the server to open facebook page and close the browser after this request .at that time the same user do login by using a different browser then that session id will exist or not for the same client??
What class is used to create Server side object ?
What is metaspace?
What is the difference between the string and stringbuffer classes?
How are the elements of a borderlayout organized?
Can I run seam with jdk 1.4 and earlier?
what is an isolation level?