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. Here i posted a good example with spring. Here rea
View Tutorial          By: Vikash K Agarwal at 2011-11-02 12:02:50

2. How to delete file button
View Tutorial          By: Chinzoo at 2013-04-13 13:30:18

3. Pl send some sample program for speech to text wit
View Tutorial          By: gokul at 2012-09-27 10:28:19

4. Thank you, that was short and enough :)
View Tutorial          By: Bilal korir at 2014-05-20 21:37:12

5. import java.util.*;

public class de

View Tutorial          By: Virudada at 2012-05-05 06:27:22

6. Very good. but why i can search data then report v
View Tutorial          By: ARMAN AHMED at 2015-04-27 13:18:04

7. the program does run thank you for that .....

View Tutorial          By: VIKRAM at 2007-03-12 13:34:24

8. my code is unable to open included files
ho

View Tutorial          By: MANAS at 2013-09-08 05:44:46

9. Thanks, it solved my problem with "sun.securi
View Tutorial          By: haasdg at 2013-10-29 14:12:51

10. //Convert numbers to word as per Indian number sys
View Tutorial          By: Abhishek at 2011-09-05 10:42:20