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



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. I download this program, but I need how to run. wh
View Tutorial          By: prabha at 2011-06-21 04:52:42

2. Hi,
I am designing a client server multipla

View Tutorial          By: Varun Gupta at 2012-10-15 00:01:57

3. nice article..
View Tutorial          By: yummy at 2010-01-05 21:18:35

4. can you give the program about the fast food by us
View Tutorial          By: grace at 2008-09-22 00:48:37

5. What a wonderful site for beginners? Now I can pra
View Tutorial          By: Kafedha Rwezaula at 2010-06-03 04:39:59

6. Anyone can send me the java code for send and rece
View Tutorial          By: Alvin at 2008-03-21 01:12:50

7. Awesome code workings fro me thank you so much :)
View Tutorial          By: Shripad at 2012-01-24 08:58:03

8. very nice tutorial.. keep it up. cheers

View Tutorial          By: chanchal at 2013-01-24 06:54:23

9. realy very nice artical it give good understable
View Tutorial          By: vivek at 2009-06-19 01:27:46

10. Thanks a lot.. it made my concepts of memmove,mems
View Tutorial          By: Rimmi Jain at 2009-07-23 06:42:01