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 / koushik1121

class Animal
{
static void meth1()
{
System.out.println("THIS IS A METHOD");
}
}
class Dog extends Animal
{
static void meth1()
{
System.out.println("THIS IS An overriding METHOD");
}
}
public class Test2 extends Dog
{

public static void main(String args[])
{

((Animal)new Dog()).meth1();
}

}

if static method can be overriden output of the above
program should be
THIS IS An overriding METHOD
because overriden depends on object type not reference type

but real output is
THIS IS A METHOD
depending upon the reference Animal for Dog object.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do we need to override service() method

1786


How database connectivity in XML is achieved?

2284


Name three subclasses of the component class?

1159


What is the purpose of the notifyall() method?

1092


what is a non-repeatable read?

2524


What is message driven beam?

1120


What is a clone?

1121


Why doesn’t the focus feature on the tag work in every circumstance?

1171


What is Remote Server?

2253


What is the difference between static and non-static with examples?

1995


Java is fully object oriented languages or not?

1073


Is a class a subclass of itself?

1314


Which containers use a border layout as their default layout?

1198


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

1156


How task's priority is used in scheduling?

2340