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



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. i wrote ocjp exam on oct 27,2012. But still i didn
View Tutorial          By: Yashwinkkumar R at 2013-02-17 09:05:29

2. clearly explained the pgm logic....
thnx...

View Tutorial          By: Akshaya at 2011-11-24 04:12:36

3. Thanks a lot. It solved my problem in a second.
View Tutorial          By: Suddy at 2010-03-25 14:56:10

4. Thanks for the explanation.
It makes sense

View Tutorial          By: Miguel JImenez at 2009-05-10 14:28:46

5. it is very understandable thanku very much......
View Tutorial          By: manogna at 2010-10-13 02:24:06

6. Easy and Wonderfulimple Example...to undersatnd th
View Tutorial          By: Chaitanya at 2010-04-04 02:27:04

7. Nice Explanation.....
View Tutorial          By: Vinoth at 2012-06-20 09:37:21

8. this total example is copy paste from the Herbert
View Tutorial          By: Parna at 2012-06-03 05:16:37

9. Hi,
I am Mahesh. i want to sending sms cod

View Tutorial          By: Mahesh at 2011-05-20 05:24:22

10. hi Ashray P Shetty,
I want assistance in th

View Tutorial          By: Shabbir Manasawala at 2010-11-19 02:02:43