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 / chitij mehrotra

Yes static method in the super class is inherited in the sub
class. See the example:

class Superclass
{
static int id;

Superclass()
{
id = 1;
}

public void show()
{
System.out.println("This is a non static method");
}

public static void value()
{
System.out.println("Super class static method");
}
}

class Subclass extends Superclass
{

}
public class Example
{
public static void main(String[] args)
{
Subclass sub = new Subclass();
System.out.println(Superclass.id);
Superclass.value();
System.out.println(Subclass.id);
Subclass.value();
}
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you find the maximum number from an array without comparing and sorting?

1082


What is method overloading in java ?

1037


What is a constructor overloading in java?

996


What is pojo class in java?

1018


Explain the difference between jvm and jre?

991


Explain the difference between association, aggregation and inheritance relationships.

1039


How many types of literals are there in JAVA?

1007


What is nullpointerexception in java?

1058


What is immutable state?

954


How many bytes is double?

927


What is import java util arraylist?

1124


When we should use serialization?

976


Tell me how many ways are there to initialise an integer with a constant.

1072


What is api in java?

943


What is an immutable class?

1092