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. very simple and nice examples for begineer...
View Tutorial          By: sarhand at 2010-04-21 00:57:23

2. this tutorial is awesome.. solved my doubt in seco
View Tutorial          By: Natasha at 2015-07-29 09:03:42

3. how i can used inheritence ?
View Tutorial          By: samee at 2008-02-16 12:54:27

4. Plz tell me the classes to import for this code an
View Tutorial          By: Nitin at 2009-11-10 02:54:50

5. plz send inheritance concept,how to use final,thi
View Tutorial          By: sobha at 2010-02-14 08:29:33

6. Thank you
View Tutorial          By: vbulletincoder at 2011-09-13 13:16:40

7. its very good example explains what is an abstarct
View Tutorial          By: sandeep at 2012-01-06 07:13:29

8. gud example, we welcome you
View Tutorial          By: jasim Khalid almurakh meherbani at 2010-09-20 03:14:25

9. Easy to understand.......
View Tutorial          By: Priya at 2013-02-15 10:55:52

10. Thx, this helped a lot.

How can I I

View Tutorial          By: Marko at 2008-10-09 01:32:37