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
Is singleton class immutable?
What is an inner class in java?
What is the final class?
What is generic type?
What is an exception in java?
Is java same as core java?
What is meant by inheritance and what are its advantages?
What is the difference between reader/writer and inputstream/output stream?
What is integer parseint?
What is a constructor, constructor overloading in java?
What is the difference between an inner class and a sub-class?
What is a values collection view ?
What is string and its types?
List some features of the abstract class.
How do generics work?