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



Ask a Question

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. I want to use the same code in c++,
Can a

View Tutorial          By: vijay at 2009-09-26 00:47:02

2. hello sir , i just implement your code and modify
View Tutorial          By: tushar at 2012-01-31 05:21:37

3. Very nice tutorial :)

I have teste

View Tutorial          By: yannoo95170 at 2015-06-18 00:30:26

4. Thanks..
Short & Sweet Description.

View Tutorial          By: Prashaad at 2012-02-23 17:37:14

5. its easy to understand the complete history of jav
View Tutorial          By: Arun Tony at 2011-04-10 07:12:04

6. Aoa. could anybody guide me about jsf with hibern
View Tutorial          By: imtiaz afridi at 2011-12-03 12:19:04

7. Hi Ramlak

First of all thanks for u

View Tutorial          By: Vikas sharma at 2010-05-08 01:09:31

8. It was sooo helpful for me
Thanx and keep i

View Tutorial          By: Shan at 2010-04-13 09:41:01

9. If I want to read input from A PDF what should I d
View Tutorial          By: thiru at 2015-08-12 10:57:51

10. i want every important questions in .net 3.5 and j
View Tutorial          By: pawan at 2011-07-28 06:17:25