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 / kino

Unlike data fields, method names can be duplicated. This is
an important feature that allows method overriding, which
in turn facilitates polymorphism in the design of object-
oriented programs. Method overriding allows a subclass to
provide its own implementation of a method already provided
by one of its superclasses. When a method is called on an
object, IDL searches for a method of that class with that
name. If found, the method is called. If not, the methods
of any inherited object classes are examined in the order
their INHERITS specifiers appear in the structure
definition, and the first method found with the correct
name is called. If no method of the specified name is
found, an error occurs.

We can think of overriding as redefining. When we want to
redefine an inherited behaviour in a more specialised way,
we must provide implementation with the exact method
signature as the inherited method (that we want to
redefine).


For example:

If I define class A:
class A{
void m(){
}
}
We can be making objects from A like this:
A a = new A;
And we can call its method m like this:
a.m();

If we also define class B as a child of A like this:
class B extends A {
}
Then we know it inherits method m from its parent, class A

So we can do this:
B b = new B();
b.m();
The above works because m is inherited.

if u dont understand go through this link.
http://www.tgs.com/support/oiv-java-
release_notes/extension/guide_content.html

Is This Answer Correct ?    3 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is double data type?

725


What is toarray method in java?

751


Tell me the Importent classes in net package?

1751


What is java lang string?

741


What is class and object in java?

742


What is the difference between scrollbar and scrollpane?

813


What does sprintf return?

788


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

793


Is 9 a prime number?

640


How does a for loop work java?

758


If an application has multiple classes in it, is it okay to have a main method in more than one class?

743


Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.

1805


What does the “static” keyword mean?

801


Explain the importance of throwable class and its methods?

761


What is arrays sort in java?

743