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. Yes the article is good and useful...!
View Tutorial          By: Regalla Naresh Reddy at 2009-04-12 23:16:24

2. php-cgi.exe return popup "is not a valid Win3
View Tutorial          By: noob at 2013-06-30 09:47:38

3. [English]
Good morning ... the question ari

View Tutorial          By: Federico at 2012-06-01 13:55:13

4. Hi,
I want to read the barcode and print it

View Tutorial          By: Santu at 2013-03-12 18:15:18

5. Great article. The simple example used easily make
View Tutorial          By: Nikhil at 2009-11-13 08:38:41

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

7. thank you
View Tutorial          By: cutiegurl at 2011-01-18 20:23:39

8. i am in beginning level, i tried by this code. but
View Tutorial          By: Shahana Akter at 2014-09-09 10:30:21

9. please send detail informatoin about j2me.. send a
View Tutorial          By: Saranya at 2011-07-06 03:00:21

10. Hi
I tried to use this class , I don't get

View Tutorial          By: arnav at 2015-03-27 06:01:22