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. Imports System.Web
Imports System.Net.Mail<

View Tutorial          By: Naresh at 2011-05-24 07:27:12

2. vinod kumar for j2me app development we need one I
View Tutorial          By: saurabh dixit at 2013-04-18 09:59:23

3. Hi,
I have problem of calling javascript fu

View Tutorial          By: Shakti Prasad Priyakumar at 2008-06-06 06:11:52

4. Good tutorial sir
View Tutorial          By: vinay at 2012-01-28 12:38:30

5. it's cool
but on other way it is indeed har

View Tutorial          By: johncarlo at 2009-02-05 04:44:13

6. Awesome post....
View Tutorial          By: Zeeshan Ali Ansari at 2012-11-24 06:35:20

7. very good cod
View Tutorial          By: moly at 2007-03-13 08:17:40

8. Everything is running.... But it doesn't send....
View Tutorial          By: Amirtharaj at 2009-04-14 05:26:26

9. Comment: Just for future readers: (apart from the
View Tutorial          By: Anonymous at 2013-05-17 08:53:20

10. thanks ........... its so easy and interesting to
View Tutorial          By: sammy at 2011-07-25 00:47:44