Comment on Tutorial - Inheritance Example in Java By Watson



Comment Added by : Adil khan

Comment Added at : 2013-02-12 06:37:17

Comment on Tutorial : Inheritance Example in Java By Watson
I lit'l modified the above program for main class, Its executing for me:

public class InheritanceBicycle {

public static void main(String args[]) {

//create the objects of Bicycle parent class
Bicycle B = new Bicycle(10, 20, 30);
//create the objects of Bicycle child class mountainBike
MountainBike m = new MountainBike(1, 2, 300, 4);
// for Bicycle
System.out.println("value of speed of bicycle " + B.speed);
B.speedUp(7);
System.out.println("value of speed after increase " + B.speed);
System.out.println("value of speed of mountainbike " + m.speed);
m.speedUp(7);
System.out.println("value of speed after increase " + m.speed);

}
}


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. Exception in thread "Thread-0" java.lang
View Tutorial          By: yash at 2009-09-16 06:12:32

2. when I exported the data to excel there is a value
View Tutorial          By: mizhelle at 2015-10-10 13:17:56

3. Thanks a lot! This really helped!!!
View Tutorial          By: SuperSeppel13 at 2009-04-14 04:25:06

4. i want jsp code
View Tutorial          By: KIRTHANA at 2015-07-31 05:29:04

5. Thank alot
View Tutorial          By: Naganatarajan at 2010-01-07 05:54:17

6. Hi,
I want to read the barcode and print it

View Tutorial          By: Santu at 2013-03-12 18:15:18

7. Really nice explanation...
nice to understa

View Tutorial          By: Parth Kansara at 2011-06-21 02:11:52

8. why the code had error in status???
View Tutorial          By: matuz at 2011-11-13 11:35:34

9. thanks. it helped a lot!
View Tutorial          By: lateforbus at 2013-04-25 03:35:24

10. Hi DILIP !
Can you plz help me I have an ex

View Tutorial          By: Bull at 2012-01-25 16:16:36