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 the relationship between an event-listener interface and an event-adapter class?
Which textcomponent method is used to set a textcomponent to the read-only state?
hi friends, i have done my BE(CSE)at 2011 then i have joined one company before they asked me 50k so i paid but now they telling no project here so we r going to close like that so now i need any job i have good knowledge in core java and j2ee(jsp,servlet,jdbc) so if u know any job pl help me
When a thread blocks on i/o?
What are the benefits of detached objects?
Describe responsibilities of Activator?
Can I use javascript to submit a form?
What event results from the clicking of a button?
Is infobus easy to use?
What is RMI and what are the services in RMI?
What is glasgow?
What is chat area? Explain.
Difference between DurableSubscription and non- DurableSubscription?
Difference between hashmap and hashtable?
What are various types of class loaders used by jvm?