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
How do you check if a number is a perfect square?
What is the final variable?
FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?
Explain illegalmonitorstateexception and when it will be thrown?
What is string manipulation?
What is internal iteration in java se 8?
What is the use of private static?
what are the high-level thread states? : Java thread
What is the definition of tree ?
Why does abstract class have constructor?
Is void a wrapper class?
Give few difference between constructor and method?
Is main a keyword in java?
What is the syntax and characteristics of a lambda expression? Explain
What is field name?