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

What are the different methods of identifying an object?

1080


Which class is the immediate superclass of the menucomponent class?

1204


What is the difference between RMI and Corba?

2749


What is a sessionfactory? Is it a thread-safe object?

1220


what is a non-repeatable read?

2430


Why won’t the jvm terminate when I close all the application windows?

1247


What are the diff types of exception?

1061


Why is string immutable in java?

1102


What do you need to set-up a cluster with jboss?

1077


Why use a datasource when you can directly specify a connection details? (in a J2EE application)

4276


How can I scroll through list of pages like the search results in google?

969


Explain how will the struts know which action class to call when you submit a form?

962


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

1095


Have you used threads in Servelet?

2509


What are the different types of exception?

1037