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 / kv
The answer lies in Object Oriented concept. When you are
overriding a method, you overriding the internal details of
default behavior. But your interface to external world is
not changed. Example, Base class employee has a method
commuteToWork(). All the manager in the company has given
the company car and a driver. Their implementation of
commuteToWork will be different from the non manager
employees. If you add a new method saying
commuteToWorkByCar(), every Monday morning you would need to
call different method for each subtype of employee. Hope it
will help.
| Is This Answer Correct ? | 13 Yes | 23 No |
Post New Answer View All Answers
How to Sort Strings which are given in List and display in ascending order without using java api.
Can we declare register variable as global?
Can you extend singleton class?
Why does java does not support multiple inheritance? Explain
How to display names of all components in a Container?
Can inner class extend any class?
What are the restrictions imposed by a Security Manager on Applets?.
What is the list interface in java programming?
If an application has multiple classes in it, is it okay to have a main method in more than one class?
How can we create objects if we make the constructor private ?
What is multi level inheritance in java?
Are strings immutable in java?
How do you check if a character in a string is a digit or letter?
What are the differences between c++ and java?
What happens when you add a double value to a string?