Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a buffer in computer?

935


What is a line break?

971


What is a flag and how does it work?

934


Differentiate between array list and vector in java.

1061


How can you handle java exceptions?

961


What is difference between equal and == in java?

902


What is an inner class in java?

903


What is meant by javabeans?

1026


How can we create a synchronized collection from given collection?

1036


Is void a data type?

899


How to implement a multithreaded applet?

2607


What is static synchronization?

1033


how to one war file class to another war file class?

2016


If an object is garbage collected, can it become reachable again?

943


What is variable length arguments in java?

906