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

What is not thread safe?

922


Explain the importance of finally over return statement?

992


Is it necessary for the port addresses to be unique? Explain with reason.

964


What is type safety in java?

899


Explain the private field modifier?

1025


Can a class extends itself in java?

969


What is string data type?

906


Difference between this() and super() in java ?

1024


When can an object reference be cast to an interface reference in java programming?

955


What is the difference between a synchronized method and a synchronized block?

1014


Can java list be null?

943


What is finalize() function in java?

955


Explain the difference between call by refrence and call by value?

972


What is jar?

1067


What is a java predicate?

914