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. Excellent example !!!
View Tutorial          By: mah at 2010-11-27 04:06:22

2. Thanks a lot .. Great work!!
View Tutorial          By: MonamAlwerfally at 2013-03-26 14:41:29

3. I HAVE ONE DOUBT.

public class Anim

View Tutorial          By: georgy at 2009-10-22 02:46:10

4. Good
View Tutorial          By: Siva Sreekanth at 2013-10-01 16:29:55

5. thanks a lot,nicely explained
View Tutorial          By: dhanushka at 2014-08-13 14:40:37

6. I need to creat class. Write in class void named r
View Tutorial          By: Aliarth at 2012-11-18 00:03:15

7. Hi Mounika, The reason to the problem is that you
View Tutorial          By: Ramlak at 2008-04-26 20:06:21

8. Simple and effective example
View Tutorial          By: Anand at 2009-02-05 00:18:10

9. Thank you for your simple example which will help
View Tutorial          By: eekld at 2012-01-04 15:46:48

10. i just got to know about this and i am really imp
View Tutorial          By: spo_mega at 2009-06-11 07:16:38