can a static method be overridden
Answer Posted / nisha
/* STATIC METHODS CANT BE OVERRRIDDEN....*/
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
dostuff();
Animal a=new Dog();
a.doStuff();
}
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
how do you Handle Front End Application data against DB with example?
Can I run seam with jdk 1.4 and earlier?
Define prototype?
we use MainFrame and using os390 for operating system with DB2 data base in IRAN and interest programing with java and use webspere for world wide,please help me where i should start?
What are callback interfaces?
What is the difference between system.out ,system.err and system.in?
What is in-memory replication?
What is the form of storage space in java?
Why doesn’t the focus feature on the tag work in every circumstance?
Java is fully object oriented languages or not?
Can I use javascript to submit a form?
Define the remote object implementation?
What modifiers may be used with an inner class that is a member of an outer class?
What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?
What is the difference between a static and a non-static inner class?