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 the byte order of byte buffer?
Is an empty arraylist null?
What is methods in java?
Why does java not allow multiple public classes in a java file ?
Does java support multiple inheritances?
What is constructor in java ?
How we can declare a static variable?
What is number data type in java?
How to set the permissions to a file in java?
What is composition in java?
What is exception in java?
What are different types of expressions?
Explain how to force the garbage collection in java.
How do I get a substring?
How do singleton patterns work?