Can we override static methods?
Answer Posted / manikandan [ gtec,vellore ]
Dear yogesh, overriding is not a compile time polymorphism
so u have to run the code.
static methods can't override
pls run below example
class test extends a
{
public static void main(String[]asd)
{
a as=new test();
as.a();//it'll not invoke a() from class test
}
static void a()
{
System.out.println("test");
}
}
class a
{
static void a()
{
System.out.println("a");
}
}
out put: a
as.a(); this line'll not invoke the method a()from class
test instead it'll invoke a a()method from class a so there
is no overriding.
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is r * in math?
Differentiate between stringbuffer and string?
What are the types of methodology?
What is the do while loop syntax?
What is the use of string and stringbuffer?
Can we write class inside a class in java?
What do you mean by light weight and heavy weight components?
Can we extend immutable class?
What are peerless components?
What is java in simple terms?
What is java volatile?
What is codebase?
What is the difference between the ">>" and " >>>" operators in java?
What is serialization in java?
Explain the features of interfaces in java?