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
Which class is the superclass of all classes?
State the significance of public, private, protected class?
What is difference between wait and notify in java?
java Technical questions asked by JPMC
When should I use singleton pattern?
What is singleton class and how can we make a class singleton?
What interface is extended by awt event listeners?
What do you understand by private, protected and public?
How much ram can a 64 bit processor theoretically?
For class CFoo { }; what default methods will the compiler generate for you>?
What is the meaning of variable in research?
Explain the advantages of packages in java?
What are the restriction imposed on a static method or a static block of code?
What is private public protected in java?
What is broken and continue statement?