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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. i wanted to know the rules how they are used like
View Tutorial By: shlok gupta at 2012-03-24 11:44:24
2. You are good work ,an axplane is so gread
View Tutorial By: chetan at 2009-06-08 11:58:51
3. i want to get the SCJP ceretificate plz anybody ca
View Tutorial By: arpita kotadia at 2012-09-01 06:50:03
4. Bitwise OR is a pipe (|), not a logical NOT (!)
View Tutorial By: Martijn at 2011-06-21 10:49:29
5. Hello,
I was able to rectify port/
View Tutorial By: Harsh at 2011-10-09 16:54:06
6. Using HTTP Redirect as per your suggesion, worked
View Tutorial By: Balram at 2008-03-21 01:27:02
7. thank you
View Tutorial By: latif mohammad khan at 2013-01-18 09:53:18
8. Design program with given algorithm---
View Tutorial By: siddhant at 2014-10-11 13:19:25
9. Hi Jim, to get the code for this clock, right clic
View Tutorial By: Rajan at 2008-04-11 08:25:03
10. How do I insert an image in a list? I am using Vis
View Tutorial By: anu at 2010-04-16 03:07:00