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. Fantastic yaar .realy very good n simple example..
View Tutorial          By: Satya at 2012-10-11 09:33:17

2. From the last 2 year. i'm working on hibernate fra
View Tutorial          By: nick at 2011-01-03 02:11:48

3. can i using stack in microsoft access 2007
View Tutorial          By: pxin at 2015-03-24 05:45:56

4. I want inserted switch statement in my program,
View Tutorial          By: shah at 2011-02-07 01:11:12

5. Great stuff - helped me setting up the company SQL
View Tutorial          By: JW at 2011-07-11 12:09:19

6. In my Midlet class there is a constructor which i
View Tutorial          By: nicolas at 2011-11-12 21:35:58

7. why can't we download & install keybasic on ph
View Tutorial          By: jimoh abiodun at 2013-04-14 13:06:18

8. I have no mounted the sd card, and I have the &quo
View Tutorial          By: Cgamboa at 2012-12-01 06:39:14

9. M finding difficulty in understanding Java. Can an
View Tutorial          By: Sunil at 2010-09-28 03:54:57

10. Hi i 've used this SMSClient.java in my simple pro
View Tutorial          By: Prakah at 2011-12-22 17:10:48