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 the exact difference in between Unicast and Multicast object? Where will it be used?
Can we create object of static class?
Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?
What is numeric function?
What is difference between classpath and path variables in java?
How are this() and super() used with constructors in java programming?
How we can execute any code even before main method?
what is ststic with example
Why java applets are more useful for intranets as compared to internet?
How do you use nextline in java?
What’s the difference between unit, integration and functional testing?
What is xslt in java?
What does jenkins do?
Is space a character in java?
What does string mean in java?