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. Hi puru, The syntax is substring(int startIndex, i
View Tutorial          By: Fazal at 2008-09-12 20:17:53

2. Your explanation is perfectly clear and not in nee
View Tutorial          By: Percy at 2009-06-08 14:14:39

3. This is pretty straightforward and got me to under
View Tutorial          By: Renoir Boulanger at 2009-09-01 09:49:24

4. Great tutorial. Thanks guys.
View Tutorial          By: John D at 2009-03-21 11:01:58

5. As C does not support Function Overloading, there
View Tutorial          By: N at 2013-03-06 00:27:14

6. Except for when you're programming low level hardw
View Tutorial          By: Jonathan H at 2012-05-10 08:46:48

7. abstract class A {
abstract void callme()

View Tutorial          By: satish at 2012-04-07 10:35:38

8. At a writing of the big program in a team comments
View Tutorial          By: vlad at 2011-05-13 12:29:01

9. sir every time we are using this.wedth(for example
View Tutorial          By: praveen kumar at 2011-06-28 01:33:44

10. Hi, i am new java, and i want to become gud develo
View Tutorial          By: amit at 2012-02-16 12:21:25