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 / konthoujan dhanabir singh

static method cannot be overriden to non-static.so static
method can be overriden to static.
the above example is true in static way
e.g.

class Animal {
static void doStuff() {
System.out.print("a ");
}
}

class Dog extends Animal {
static void dostuff() { // it's a redefinition,
// not an override
System.out.print("d ");
}

public static void main(String [] args) {
Animal [] a = {new Animal(), new Dog(), new Animal()};
for(int x = 0; x < a.length; x++)
a[x].doStuff(); // invoke the static method
}
}

Running this code produces the output:
a a a
Some case:
in the subclass Dog, if the method dostuff() is not
static,it will be compile time error in the above code
block .

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?

1182


what is meant by JRMP?

2429


Explain phantom read?

2273


Why are component architectures useful?

1117


How would you create a button with rounded edges?

1237


What are transaction attributes?

1156


In our urls and in the text of the buttons we have comma. Its causing an error. Is there a way to change the delimiting character for the menu arguments?

1221


Is infobus easy to use?

1079


Name three component subclasses that support painting?

1122


What is the difference between the ‘font’ and ‘fontmetrics’ class?

1207


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

1261


What is Stream Tokenizer?

2320


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

1063


What is difference between object state and behavior?

1147


What is the highest-level event class of the event-delegation model?

1159