In Inheritence concept, i have a static method in super
class and i am inheriting that class to one sub class.in
that case the static method is inherited to sub class or
not????
Answer Posted / mohan
static methods can be inherited into sub class also..we can
override the static methods also..
Here is the example code
package files;
class A
{
public static void test()
{
System.out.println("static override A");
}
}
class B extends A
{
public static void test()
{
A.test();
System.out.println("static override B");
}
}
public class StaticInheritance {
public static void main(String args[])
{
B b = new B();
b.test();
}
}
Output:
static override A
static override B
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a buffer in computer?
What is a line break?
What is a flag and how does it work?
Differentiate between array list and vector in java.
How can you handle java exceptions?
What is difference between equal and == in java?
What is an inner class in java?
What is meant by javabeans?
How can we create a synchronized collection from given collection?
Is void a data type?
How to implement a multithreaded applet?
What is static synchronization?
how to one war file class to another war file class?
If an object is garbage collected, can it become reachable again?
What is variable length arguments in java?