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

What is the difference between ear, jar and war file?

1185


What is colon_pkg_prefixes and what is its use?

2588


what is meant by JRMP?

2430


Describe responsibilities of Activator?

2353


What are the call back methods in entity bean?

1113


How would you detect a keypress in a jcombobox?

1185


Define prototype?

1122


Difference between loadclass and class.forname?

1095


What is the difference between long.class and long.type?

1174


Why are component architectures useful?

1119


When is the best time to validate input?

1148


how i secure my site with the https protocol.what are the steps?

2392


What state does a thread enter when it terminates its processing?

1119


Is there a guarantee of uniqueness for entity beans?

1058


What value does readline() return when it has reached the end of a file?

1138