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

Difference between loadclass and class.forname?

1099


How to determine SGA site?

2618


What are transaction attributes?

1162


Java is fully object oriented languages or not?

1074


Can I map more than one table in a cmp?

1132


What are the different methods of identifying an object?

1132


What is RMI and what are the services in RMI?

1252


What is the difference between the session.get() method and the session.load() method?

1126


Describe activation process?

2721


What is the purpose of the notify() method?

1140


What you mean by COM and DCOM?

1121


What do you know about seam?

1134


difference between  ejb,struts,hibernate,spring and jsp

2925


What restrictions are placed on the values of each case of a switch statement?

1062


Difference between hashmap and hashtable?

1233