can a static method be overridden
Answer Posted / koushik1121
class Animal
{
static void meth1()
{
System.out.println("THIS IS A METHOD");
}
}
class Dog extends Animal
{
static void meth1()
{
System.out.println("THIS IS An overriding METHOD");
}
}
public class Test2 extends Dog
{
public static void main(String args[])
{
((Animal)new Dog()).meth1();
}
}
if static method can be overriden output of the above
program should be
THIS IS An overriding METHOD
because overriden depends on object type not reference type
but real output is
THIS IS A METHOD
depending upon the reference Animal for Dog object.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is a modular application? What does module-relative mean?
Write a program to show synchronization?
Explain about RMI Architecture?
what is the use of State Factories?
What are callback interfaces?
Define aop(assepct oriented programing)?
How to determine SGA site?
What modifiers may be used with an inner class that is a member of an outer class?
Java is fully object oriented languages or not?
Can I import same package/class twice? Will the jvm load the package twice at runtime?
What event results from the clicking of a button?
How will you pass parameters in RMI? Why do you serialize?
What is Remote Server?
What is the purpose of the wait(), notify(), and notifyall() methods?
What are the call back methods in entity bean?