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. its not solve my problem.i.e
the concept is

View Tutorial          By: murli at 2010-10-02 23:23:11

2. When copying this code into my java IDE, should i
View Tutorial          By: Barabas at 2010-02-11 03:57:09

3. i need jsp code for free sms send.
if anybo

View Tutorial          By: Harish at 2008-10-30 03:20:31

4. need to be explained more
View Tutorial          By: parul at 2011-06-30 08:34:29

5. this is not good example we want better...
View Tutorial          By: sabari nathan.p at 2011-06-15 03:27:18

6. it would be very helpful if you demonstrated how t
View Tutorial          By: newcoder at 2011-10-24 17:40:25

7. i have connected my phone through bluetooth and us
View Tutorial          By: nikitha at 2013-02-05 09:07:34

8. very nice thank you so much my dude
View Tutorial          By: mohd at 2010-07-28 02:40:23

9. Microsoft VB.net 2008 not showing Crystal Report V
View Tutorial          By: Ali at 2011-11-30 03:21:00

10. Hi, this blog answers my questions but what is the
View Tutorial          By: Edu at 2009-09-20 00:19:27