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

Can you give me a simple example of using the requiredif validator rule?

1127


What are the oops concept?

1078


What you mean by COM and DCOM?

1065


How would you detect a keypress in a jcombobox?

1140


Can I have an action without a form?

1107


What is the diffrence between a local-tx-datasource and a xa-datasource?

1054


whats is statement and procedure

2212


Describe, in general, how java's garbage collector works?

1039


what is meant by JRMP?

2354


What happens when a thread cannot acquire a lock on an object?

1038


Where can I find seam examples and documentation?

1099


Why do I get a duplicate name error when loading a jar file?

1150


In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?

2102


Why is actionform a base class rather than an interface?

1064


Why a component architecture for the java platform?

1217