Comment on Tutorial - Method Overriding in Java By Henry



Comment Added by : sam

Comment Added at : 2011-06-24 15:13:34

Comment on Tutorial : Method Overriding in Java By Henry
using a same name ,return type and parameter type for a method in a derived class as that of a method i.e, present in the base class is known as method overridind
EX:-
class x
{
void show()
{
system.out.pln("hey");
}
}
class y extends x
{
void show()//notice void show ()is present in both the base class and the derived class//
{
system.out.pln("hello");
}
}
class test3
{
public static void main(string n[])
{
y y1=new y();//y1....derived class object//
y1.show();
}
}

though it`s possible to invoke the base class method within the derived class object.
When the statement y1.show();is exicuted,the show() of Derived class(i.e,y) is invoked reasulting in the out put 'hello'.
the base class method show() is said to be hidden from the derived class method show(). In order to exicute show()of the base class therre are twomethods
1. By creating an object for th base class.
2. By using super keyword


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Daniel Jonsson, you should be thankful to this art
View Tutorial          By: dole at 2011-11-12 06:44:42

2. Nice one
View Tutorial          By: Kalpana at 2009-11-17 02:04:14

3. Thanks for posting the JAVA source code!!
View Tutorial          By: Coder at 2010-07-29 11:41:10

4. What if I wanted POST instead of GET?
View Tutorial          By: Otto at 2011-06-12 15:38:50

5. Very nice demo. thanks! :)
View Tutorial          By: Nikhil Gala at 2012-01-13 10:03:57

6. be very careful. use of put (or any method inheri
View Tutorial          By: d at 2009-10-14 09:55:23

7. I request to java beacuse i hope java language

View Tutorial          By: jeey at 2011-07-06 07:59:07

8. @pawan: Wow. Your comment is museum-quality art, a
View Tutorial          By: Steve at 2013-02-21 20:30:47

9. its very helpful..thank you..
View Tutorial          By: roja at 2013-06-16 12:37:32

10. helpfull !!!!
View Tutorial          By: Anonymous at 2009-05-12 03:48:15