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. The following line in the code
((NewThread)

View Tutorial          By: Carlos at 2009-11-18 14:34:51

2. Hello Mr. Developer of above proj....plz let me kn
View Tutorial          By: Prakash Vishwakarma at 2011-07-08 10:02:22

3. hi RAMLAK i am akankshain and getting these erro
View Tutorial          By: akanksha at 2011-12-06 10:15:47

4. pls can any one have any idea about storing the ca
View Tutorial          By: souhir at 2010-01-30 11:04:48

5. i am new to java programming plz please provide me
View Tutorial          By: Mahammad musthaq at 2012-05-31 14:02:10

6. nice intelligent work
View Tutorial          By: santosh at 2010-11-28 01:18:50

7. why we use the java in networking and What are the
View Tutorial          By: ali mohammed at 2015-10-11 23:03:40

8. only last code is gud one (DateFormat )... otherwi
View Tutorial          By: Gaurav at 2013-01-04 09:18:43

9. Thanks a lot.
View Tutorial          By: Nirwana at 2009-04-24 05:17:10

10. BIG Thanks for such wonderful tutorial :) :) :)
View Tutorial          By: dhruva at 2013-07-10 08:56:27