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. i m new in java plz send some programs on packages
View Tutorial          By: zainul hasan mirza at 2009-08-31 02:28:32

2. It works like a charm. Thanks a lot.
View Tutorial          By: Balram at 2008-08-22 21:18:44

3. It encourage the learners

Learners

View Tutorial          By: sureshkumar p at 2010-12-22 04:13:04

4. the example is from herbert schildt complete ref..
View Tutorial          By: dui_prithibi at 2012-11-26 12:59:15

5. Really a appriciatable one. Can u plz send the cod
View Tutorial          By: Jeevan at 2009-04-11 12:39:45

6. nice to learn abt it
View Tutorial          By: aice at 2012-08-25 12:49:35

7. i know this example this is in mg.hill but i want
View Tutorial          By: srikanta at 2009-11-18 00:06:57

8. please am in Nigeria, i need to know how to send a
View Tutorial          By: kay at 2009-10-15 03:06:10

9. hi,

i have a problem. I have the ti

View Tutorial          By: Felipe at 2010-02-18 05:03:51

10. how can i give me a assign value to mutldimentiona
View Tutorial          By: shinde datta at 2013-01-12 10:41:15