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!!!!!!!!!!!!
View Tutorial          By: Ramana at 2009-01-02 19:31:58

2. Thankx, the information was of great use, I apprec
View Tutorial          By: sachin at 2008-12-13 03:37:11

3. Excellent !...That explains my long-term question
View Tutorial          By: Vineeth at 2012-02-01 03:50:21

4. The static variables are not in object scope inste
View Tutorial          By: Karthick at 2011-06-29 06:55:17

5. Thanks man it is very very helpfull for me.

View Tutorial          By: qasim azam at 2011-06-15 18:09:35

6. Its tooo good to others.......& easy
View Tutorial          By: Abhishek at 2010-03-31 23:57:07

7. Thanks Jagan!!!!!!
View Tutorial          By: Maahe at 2012-07-06 05:23:51

8. I have a small query: Is it interface allow method
View Tutorial          By: vijay at 2012-04-20 10:34:30

9. thank you...as a beginner this info very useful fo
View Tutorial          By: snigdha at 2012-10-17 11:41:39

10. Very concise, but it would be more helpful without
View Tutorial          By: Randy at 2010-11-17 14:16:01