what is the purpose of method overriding in java where v r
completely re-defining a inherited method instead y can't v
create a new method and define.If the question is very silly
plz excuse me and do reply.Thank U!

Answer Posted / sridharan

We know method overriding will be coming in inheritance.
Consider a mother and her daughter.
Lets think mothers will cook, so her daughter will also
cook. One day mother cooked a biryani for her daughter. By
using the method

cookBriyani(rice,vegetables,water,salt). {

// mother style of cooking
}
But her daughter didn’t like it. So her daughter decided to
prepare biryani by herself. She is also going to use same
ingredients but she is going to prepare in her style.
Daughter method is

cookBriyani(rice,vegetables,water,salt){
// daughter style of cookling
}
Daughter made also biryani so without changing the
name i.e cookBriyani(), also she used same ingredients (i.e
rice,vegetables,water,salt) i.e same parameter but she
prepared in different style.

Is This Answer Correct ?    67 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the primitive type byte?

563


Explain abstract class in java?

548


Does google use java?

518


How many bytes is a char in java?

518


How to pass arraylist to stored procedure in java?

533






Can static methods access instance variables in java?

560


How do you replace all in word?

512


What is string buffer?

493


What is autoboxing in java?

591


How to sort double array in java?

575


What does business logic mean?

493


How many bytes is 255 characters?

539


Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?

593


What is string pool in java?

550


How to make a write-only class in java?

562