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. Would u please provide me with a solution about ho
View Tutorial          By: milan at 2011-02-17 05:39:38

2. hello everyone

i want to implement

View Tutorial          By: Prateek at 2010-09-05 00:40:57

3. Hats off man !!! Very Simple & Straightforward
View Tutorial          By: Nitesh at 2013-01-06 00:50:53

4. thanks for the help! your tutorials really help us
View Tutorial          By: Mon Bernie Gucor at 2009-02-20 19:57:35

5. You do not give an example on fillratio i want to
View Tutorial          By: reguieg at 2015-08-23 20:53:50

6. good for us
View Tutorial          By: soumen chakraborty at 2008-08-25 01:28:30

7. i searched a lot of sites but found the answer her
View Tutorial          By: ALIEN ATTACK at 2012-01-09 09:39:36

8. The SAX Parser code has a problem for files of gre
View Tutorial          By: Mark Nelson at 2011-11-14 20:16:41

9. Superb

many thanks to you Mashoud.

View Tutorial          By: orchidouest at 2009-05-10 12:58:53

10. Thanks it did help to get complete clarity
View Tutorial          By: Vivek The Great at 2012-05-07 17:31:32