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 about main thread in java?

638


Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx

1595


If an object is garbage collected, can it become reachable again?

536


Explain listiterator and methods in listiterator?

539


Justify your answer that you can't define a method inside another method in java, if you can then how?

596






What is r * in math?

540


What happens if we override only equals?

572


What is the benefit of singleton pattern?

514


why java uses class level type casting ?

2242


What is purpose of keyword void?

556


Difference between error and exception

4995


What are exceptions

633


What is private protected in java?

543


Write a java program for binary search?

595


Why Java is not pure Object Oriented language?

634