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. Hi : Pulkit Malviya .I think that book has coding
View Tutorial          By: Anand at 2012-11-04 14:13:50

2. nice material
View Tutorial          By: ravi at 2008-12-24 00:40:12

3. Hi All........
People those who are ge

View Tutorial          By: Abhijit at 2013-05-28 11:24:24

4. Timely info right when I needed it. Thanks.
View Tutorial          By: Electric Vehicles at 2008-12-10 15:15:25

5. thnks a lot...
View Tutorial          By: iti at 2015-06-03 07:05:24

6. Thank you
View Tutorial          By: Angeline at 2011-06-28 06:27:12

7. You should consider using different threads that a
View Tutorial          By: Jeremy at 2010-01-13 23:02:11

8. Java is very interesting,I wish to do certificate
View Tutorial          By: Dzunisani Chauke at 2012-11-05 10:19:35

9. not good not bad...............
View Tutorial          By: mahesh at 2010-10-05 00:45:54

10. I tried to create an object on my 6th code but i a
View Tutorial          By: AARON VICU√ĎA at 2009-03-24 05:20:24