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. Thanks for the tutorial,

I have a q

View Tutorial          By: rajendra at 2013-04-29 15:37:28

2. all of codes of t-C++ ide, it is applicable to use
View Tutorial          By: jonard at 2009-06-05 20:41:39

3. Hi Satheesh, Look at http://www.java-samples.com/s
View Tutorial          By: Ryan at 2010-08-31 19:15:28

4. I am suffering with the same error as of ganesh...
View Tutorial          By: Sri Bhavani at 2008-09-30 00:18:38

5. very nice and good introduction for beginners.
View Tutorial          By: annie at 2011-11-23 06:50:32

6. Nice one....
View Tutorial          By: vinod at 2010-05-06 23:36:15

7. sach a lovely exmpl for bgnrs thanks
View Tutorial          By: aaditya at 2013-01-13 08:05:03

8. sUPER eXPLAnation
View Tutorial          By: Surendra at 2015-06-13 07:23:56

9. I am getting following error, I am using samsung m
View Tutorial          By: Ashok at 2013-08-17 05:29:02

10. This is just Great, didn't find anything like this
View Tutorial          By: Vikrant Verma at 2012-10-07 04:54:42