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 should I import for arraylist in java?

1034


Define "Access specifiers" in java.

1166


Can I use % with real numbers?

1017


Can a singleton class be inherited?

966


Is age discrete or continuous?

1129


What is the difference between procedural and object-oriented programs?

971


What is the primitive type byte?

1002


Which is the class in java?

1042


I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?

1013


What are serialization and deserialization?

1257


What is multithreading and its advantages?

1069


What is nested interface?

1008


Explain about wait() method?

1025


How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?

1443


design an lru cache in java?

1004