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



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. The example is good but there is an easy to iterat
View Tutorial          By: manish at 2013-03-24 16:21:03

2. @pooja: this method should work, although i'm sure
View Tutorial          By: Anush at 2012-07-16 08:30:58

3. Hi All,

I am new to J2ME Applicatio

View Tutorial          By: golemnagesh at 2010-12-05 22:43:50

4. i want to sending sms code in java. send me that c
View Tutorial          By: Montu at 2011-06-01 15:15:56

5. Hi Devi, After you download the 5 programs you nee
View Tutorial          By: Ramlak at 2008-04-01 01:51:42

6. Hi
Can u plz tell me how to implement this

View Tutorial          By: Rohan at 2008-09-23 05:52:31

7. This text is a plagiary of part of K&R ANSI C
View Tutorial          By: c_apprientice at 2010-11-13 07:30:11

8. package alphabets;

import java.util

View Tutorial          By: Nitish at 2013-01-25 04:06:38

9. hi
thanks for the above code
Anyone

View Tutorial          By: mjnanthini at 2010-09-29 00:59:01

10. nice example and this is very use ful
View Tutorial          By: jyothi at 2011-02-18 22:24:51