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. it is very easy to understand to the learners.
View Tutorial          By: venkat at 2010-06-19 02:37:36

2. Getting Invalid IPv4 format J2me Midp 2.0, Asp.net
View Tutorial          By: Anup at 2013-01-02 05:11:51

3. it's cool
View Tutorial          By: RInam Shah at 2011-06-20 02:48:20

4. @Vipin : vipin u r wrong,,,in reality java does n
View Tutorial          By: Arpit Tyagi at 2010-07-23 04:11:20

5. very simple example.....................
View Tutorial          By: kajal at 2015-08-22 09:28:16

6. Exception in thread "Thread-0" java.lang
View Tutorial          By: yash at 2009-09-16 06:12:32

7. werst program out put nt comming
View Tutorial          By: anu at 2012-08-02 13:09:00

8. This article is clearly showing the beauty of the
View Tutorial          By: ashok at 2012-02-25 12:51:01

9. Very informative and simple to understand. Thank y
View Tutorial          By: Rosa Vladivord at 2012-12-23 13:00:52

10. Hi Sir...
sir i am a student and I am worki

View Tutorial          By: shanthi at 2013-03-22 11:01:15