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


Please Help Members By Posting Answers For Below Questions

What is maximum size of arraylist in java?

681


What is the use of :: in java?

762


What is the benefit of abstract class?

698


Can we increase array size dynamically in java?

702


What is the loop in java?

784


What is the difference between numeric and integer?

715


What is the unit of plancks constant?

766


What is a java developer salary?

726


What happens if constructor is private?

769


what r advatages of websphere? & how to deploy?

1840


What is arraylist e in java?

709


Can we call the constructor of a class more than once for an object?

820


What is the default size of set in java?

698


What are the five major types of reference sources?

724


How do you stop a thread in java?

800