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



Ask a Question

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. Not able to store on SD card.But storing on phone
View Tutorial          By: kusuma at 2015-07-25 13:42:17

2. Thanks.It helps a lot to me.
View Tutorial          By: Sachin at 2013-05-24 19:36:36

3. I am trying to figure out what our Professor did w
View Tutorial          By: Abhishek at 2011-04-09 23:31:28

4. very brief and easy to understand description of R
View Tutorial          By: moona at 2010-05-26 22:49:26

5. hello,
how can i add a specific variable va

View Tutorial          By: Abdulla at 2014-12-05 15:30:27

6. Hi,
My problem is that how to connect the r

View Tutorial          By: Twahie at 2011-03-21 05:31:06

7. Awesome information
View Tutorial          By: Pavan Somu @ Tech Tips at 2013-01-03 18:45:30

8. Thnak you very much i got much of help for my proj
View Tutorial          By: Xshay at 2012-01-21 06:26:49

9. Simple file writer example. .............
<

View Tutorial          By: Chezhian TK at 2010-10-14 21:40:16

10. It is simple and clear.. Thnx.
View Tutorial          By: kiru at 2010-04-06 01:48:04