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 does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
what is an objects lock and which objects have locks? : Java thread
Why do we use return statement?
What is a Null object?
Which are different kinds of source code?
How to change the priority of thread or how to set the priority of thread?
What are the differences between string and stringbuffer?
What are the two environment variables that must be set in order to run any java programs?
What do you mean by synchronized non access modifier?
Which class should you use to obtain design information about an object in java programming?
Is null a string in java?
What do you understand by weak reference?
What is lazy programming?
How can we run a java program without making any object?
What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?