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. Your post helped me to resolve the SSH exception..
View Tutorial          By: Ashwini at 2008-07-14 12:47:32

2. I copied the same program for execution...

View Tutorial          By: Anusha at 2014-05-14 14:24:19

3. Please send me application for sending message on
View Tutorial          By: jigar at 2011-12-21 11:53:48

4. good;Every one can understand
View Tutorial          By: seshu at 2011-04-26 05:11:09

5. Actually, looking at the code, it looks as somethi
View Tutorial          By: Johnson at 2009-07-28 08:14:38

6. thnkss buddyy its very helpful for my assignmentss
View Tutorial          By: yamini at 2011-02-25 21:01:23

7. very good explanation,very good examples..
View Tutorial          By: sra1 at 2011-11-14 08:30:47

8. I am receiving an error as
Error java.lan

View Tutorial          By: pablo at 2014-08-03 16:10:55

9. when i use this, the textarea automatically create
View Tutorial          By: gary at 2011-06-08 07:14:09

10. Turning off hostname checking also turns off all s
View Tutorial          By: eric at 2014-01-30 18:09:05