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. hiii
i m doing my final year project on sms

View Tutorial          By: jiya at 2010-10-21 07:58:24

2. Thanks heaps, I had the file already there but it
View Tutorial          By: Jb at 2009-05-14 08:13:08

3. it really helped me...thank you...
View Tutorial          By: ram at 2015-01-22 20:12:01

4. Its working Great.
Here i want to ask one

View Tutorial          By: Manish at 2015-03-18 11:55:20

5. my code is unable to open included files
ho

View Tutorial          By: MANAS at 2013-09-08 05:44:46

6. It works great,
my code looks like this:
View Tutorial          By: Anonymous at 2009-04-11 04:19:28

7. Hi!
I would like to send a string from a j2

View Tutorial          By: beetlebrain at 2010-03-26 06:02:00

8. how to create a do while,the output wil show the m
View Tutorial          By: waa at 2009-09-02 19:23:45

9. The program will work only need to change

View Tutorial          By: LEENA NARULA at 2012-06-15 06:45:06

10. The code gives the following exception :-
<

View Tutorial          By: VIKRAM at 2007-03-11 22:56:16