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. "This happens immediately, and before any oth
View Tutorial          By: David at 2007-10-02 06:52:20

2. Thanks great tutorial..
View Tutorial          By: Abul Rahman at 2009-07-24 11:39:52

3. Hi,
Please give the better example of resou

View Tutorial          By: Keerthi at 2012-01-11 11:28:24

4. thanks bro it helped me to answer my facu
View Tutorial          By: kasmin at 2010-01-08 08:11:32

5. good
View Tutorial          By: epuri at 2008-09-09 01:05:56

6. can we print only second by using the date functio
View Tutorial          By: mukesh kumar at 2011-07-27 02:31:02

7. error is main fuuction declaration
void mai

View Tutorial          By: T.M.Prakash.MCA. at 2012-09-20 12:26:52

8. great !!!!!!!!!!!!!!!!!!!!!
View Tutorial          By: arjun at 2012-03-24 14:55:10

9. Thanks mate !!!

-- Anish Sneh

View Tutorial          By: Anish Sneh at 2010-08-18 07:42:56

10. Buenisimo tutorial, este rebuena la cosa
Gr

View Tutorial          By: Popoca at 2010-04-20 15:50:29