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

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

Java program to check if user input is an even number

Archived Comments

1. i need to code for sparse matrix in java. please
View Tutorial          By: sudhi at 2012-10-01 09:34:57

2. download jdk
View Tutorial          By: alireza esfandyarinezhad at 2011-03-07 11:52:55

3. Thanks. Helped me save few hours
View Tutorial          By: Balan at 2008-04-07 18:25:08

4. Thanks, this is exactly i am looking for. I need t
View Tutorial          By: Ankita at 2009-11-15 19:41:16

5. I dont know the reason why have a exception!

View Tutorial          By: Nguyen Tien Viet at 2008-04-05 06:01:50

6. when i try to compile the two files by executing t
View Tutorial          By: Brian at 2015-08-05 12:15:37

7. Having this error while using comm.jsr for sending
View Tutorial          By: Amit Kumar at 2013-10-15 09:04:58

8. Hi..All ...to run this programs.first of of all u
View Tutorial          By: raavi.surendra at 2011-12-29 05:34:06

9. very easy to understand ... a quite a good example
View Tutorial          By: Dinesh at 2012-09-22 18:19:45

10. There was no sharing of volatile variable in the p
View Tutorial          By: Rajesh Poppoppu at 2011-12-30 13:04:42