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 are synchronized methods and synchronized statements? : Java thread
Which programming language is most secure?
Is null a string?
What are the two basic ways in which classes that can be run as threads may be defined?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
What is join () in java?
What is equlas() and hashcode() contract in java? Where does it used?
What is the difference between a loader and a compiler?
What data type is a string?
State one difference between a template class and class template.
What’s the difference between unit, integration and functional testing?
Is set sorted in java?
What is an iterator interface in java programming?
What is a conditional equation?
How do generics work in java?