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

Explain what is synchronization?

1076


Is “abc” a primitive value?

1099


How can I avoid validating a form before data is entered?

990


Why does the tag url-encode javascript and mailto links?

990


What is scalable, portability in the view of J2EE?

2515


What are the different algorithms used for clustering?

1054


Which class is the immediate superclass of the menucomponent class?

1191


What modifiers may be used with an interface declaration?

1122


What are the different class loaders used by jvm?

1091


Is jvm a overhead?

1085


What is metaspace?

1023


What is the difference between RMI registry and OS Agent?

1129


How a component can be placed on Windows?

2846


When a thread blocks on i/o, what state does it enter?

1087


What are the types of scaling?

1078