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
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. Hi...Really nice post..But i got the error like
View Tutorial By: Nithya at 2013-04-11 09:37:50
2. Answer for Comment 4 :
" n=n++
View Tutorial By: NewB_of_java at 2012-02-16 16:52:05
3. can i also get the variable description for this p
View Tutorial By: Maya Rao at 2013-10-04 06:06:00
4. very good helped me a lot
View Tutorial By: Swaran at 2009-12-30 09:51:36
5. hey thats a superb way of explaining in plain term
View Tutorial By: Agastya at 2011-05-08 03:11:53
6. ,./;'wat i searching for is that, the complete jav
View Tutorial By: chor at 2010-03-28 23:09:37
7. Please provide web.xml file for this example
View Tutorial By: Girish at 2009-03-08 22:53:03
8. Really The Best Start for mE
View Tutorial By: neeraj at 2012-01-26 13:27:31
9. good start up fr java beginers
View Tutorial By: sandeep Ch at 2012-01-06 07:16:34
10. Thank you, that was short and enough :)
View Tutorial By: Bilal korir at 2014-05-20 21:37:12