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



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. how to read csv file using Java
View Tutorial          By: Shireesha at 2013-12-26 07:34:22

2. hi! this coding is very helpful for me thanks .
View Tutorial          By: bhuvaneshwari at 2009-10-18 23:52:58

3. this is the thread object and thread name
View Tutorial          By: narain at 2011-12-06 07:33:07

4. The code gives the following exception :-
<

View Tutorial          By: anju at 2014-03-15 07:02:18

5. Yes Left shift result is wrong its like
5

View Tutorial          By: Ragunath k at 2010-05-10 04:45:33

6. This article is very clear,short and direct to the
View Tutorial          By: N JIBRIN at 2007-03-15 11:48:26

7. my code is unable to open included files
ho

View Tutorial          By: MANAS at 2013-09-08 05:44:46

8. nice tutorial man !
View Tutorial          By: yash at 2012-11-10 05:08:31

9. hi good article with explanation
View Tutorial          By: yuganthi at 2012-09-24 05:18:35

10. Hi ,

Since both the methods in the

View Tutorial          By: Chintan at 2013-11-21 03:42:32