Comment on Tutorial - Method Overriding in Java By Henry
Comment Added by : pratham
Comment Added at : 2010-09-22 10:10:11
Comment on Tutorial : Method Overriding in Java By Henry
If i run this program----
// Methods with differing type signatures are overloaded – not
// overridden.
class A {
int i, j;
A(int a, int b) {
i = a;
j = b;
}
// display i and j
void show() {
System.out.println("i and j: " + i + " " + j);
}
}
// Create a subclass by extending class A.
class B extends A {
int k;
B(int a, int b, int c) {
super(a, b);
k = c;
}
// overload show()
void show(String msg) {
System.out.println(msg + k);
}
}
class Override {
public static void main(String args[]) {
B subOb = new B(1, 2, 3);
subOb.show("This is k: "); // this calls show() in B
subOb.show(); // this calls show() in A
}
}
THERE IS RUNTIME ERROR
Exception in thread "main" java.lang.NoSuchMethodError: main
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
Related Tutorials
Java program to get location meta data from an image
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
Archived Comments
1. nice example..thanx i was havin trouble wid timers
View Tutorial By: gunjan at 2008-06-02 03:06:17
2. import gnu.io.*;
import java.io.*;
<
View Tutorial By: Anonymous at 2013-03-29 02:39:00
3. Its really helpfull to me thanks................
View Tutorial By: AKS at 2013-08-10 06:27:43
4. Can anybody tell the steps to go ahead with the ex
View Tutorial By: Sunpenn at 2009-10-12 03:57:58
5. Thank you for your simple example which will help
View Tutorial By: eekld at 2012-01-04 15:46:48
6. Hi Grenfel, would this be possible??
View Tutorial By: Lerianne at 2012-08-20 11:37:32
7. Controlling Page Navigation in JSF - Static and Dy
View Tutorial By: chip at 2010-10-07 05:16:14
8. Superb
many thanks to you Mashoud.
View Tutorial By: orchidouest at 2009-05-10 12:58:53
9. what about (!isset)?? the isset with "!"
View Tutorial By: bali web design at 2011-04-21 12:51:38
10. this tutorial is awesome.. solved my doubt in seco
View Tutorial By: Natasha at 2015-07-29 09:03:42