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



Ask a Question

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. awesome.........
View Tutorial          By: tar at 2013-03-14 07:36:56

2. would like to have copy of clock
View Tutorial          By: jim johnson at 2008-04-10 17:30:06

3. very nice approach sir....
u make it very e

View Tutorial          By: aamir at 2011-06-15 01:29:22

4. it is very good for best practice of basics.......
View Tutorial          By: sushil ghimire at 2015-03-01 13:27:57

5. Hi there, a nice tutorial. i wanna ask, what about
View Tutorial          By: Alfa at 2013-03-06 04:04:26

6. that was gud example to explain abstract. i have d
View Tutorial          By: zishan at 2010-05-20 00:21:46

7. import java.util.*;

class Pstring<

View Tutorial          By: Bhaskar.pg at 2014-05-29 12:39:52

8. cool!!!

can you show me some sample

View Tutorial          By: eduard jacob bernido at 2008-07-14 04:01:59

9. i want some brief realtime examples
View Tutorial          By: SURYA.C at 2015-08-20 05:06:18

10. can anybody tell me the full code for sending sms
View Tutorial          By: shikha at 2008-10-13 11:43:40