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...

can a static method be overridden

Answer Posted / mayank

only static method in a subclass can over ride the static
method in the parent class.

for example

public class A {
public static int display(){
System.out.println("i an in A");
return 1;
}

}


public class B extends A{

public static int display(){

System.out.println("i an in B");
return 1;
}


/*public int display(){

}*/
}

will work fine. but if the subclass tries to override parent
class static method with a non static method it generates
compilation error.

for eg

public class B extends A{

/* public static int display(){

System.out.println("i an in B");
return 1;
}*/


public int display(){

}
}
the above code will result in compilation error.

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why a client should be multithreading? Explain.

1037


What is TL and its use?

2410


When is the best time to validate input?

1064


what are getters and setters in Java with examples?

1735


What is ioc concept & explain it?

1041


why static class in java

1724


Can I map more than one table in a cmp?

1033


How are the elements of a cardlayout organized?

1039


What is a policy?

2245


what is handle?

2317


In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?

1123


What is the map interface?

1082


How primary key is implemented in Oracle?

2383


What is an abstract method?

1007


Name three component subclasses that support painting?

1023