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. know someone how to compare various objects?

View Tutorial          By: Peter at 2009-10-07 07:32:31

2. its very nice
View Tutorial          By: keerthi at 2012-06-28 17:04:36

3. Excellent example Jagan. By the way I have a quest
View Tutorial          By: Shrihas at 2012-01-07 14:12:48

4. Please send the complete code.. thanks!
View Tutorial          By: Roger22 at 2010-03-11 00:41:07

5. public class zcxzcStack
{
//push fun

View Tutorial          By: eissen at 2014-09-22 13:32:20

6. thanx a lot.............!!!! u r best..........
View Tutorial          By: Pratik at 2010-04-12 12:41:30

7. can anybody hp me how to create a rms database in
View Tutorial          By: contractornimesh at 2011-01-04 00:12:08

8. i m a student of Bahria university,Pakistan.and th
View Tutorial          By: Rao Waseem at 2011-05-14 12:55:53

9. how can i give me a assign value to mutldimentiona
View Tutorial          By: shinde datta at 2013-01-12 10:41:15

10. very nice program but more info require
View Tutorial          By: pradeep at 2010-07-15 01:11:37