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
List out benefits of object oriented programming language?
Explain thread in java?
What is mnemonic in assembly language?
Are primitives objects?
What is an image buffer?
What is byte code and why is it important to java’s use for internet programming?
What are the differences between graph and tree?
What is oop principle in java?
What is computer compiler?
What is final, finally, finalize?
If two threads have same priority which thread will be executed first ?
What are the four pillars of java?
How the interruptible method gets implemented?
Is class is a data type?
Explain the difference between private, public, package and protected in java?