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

Which class is the superclass of all classes?

1110


State the significance of public, private, protected class?

1108


What is difference between wait and notify in java?

1143


java Technical questions asked by JPMC

5084


When should I use singleton pattern?

1030


What is singleton class and how can we make a class singleton?

1100


What interface is extended by awt event listeners?

1058


What do you understand by private, protected and public?

1041


How much ram can a 64 bit processor theoretically?

902


For class CFoo { }; what default methods will the compiler generate for you>?

1075


What is the meaning of variable in research?

1018


Explain the advantages of packages in java?

919


What are the restriction imposed on a static method or a static block of code?

1060


What is private public protected in java?

1034


What is broken and continue statement?

999