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. hi
very tnx for your code

View Tutorial          By: Moji at 2012-08-19 16:06:53

2. When I tried to run this code, I got time out ***
View Tutorial          By: Gandhi at 2009-06-04 06:20:48

3. i need to code for sparse matrix in java. please
View Tutorial          By: sudhi at 2012-10-01 09:34:57

4. if done all the steps but i have found out this er
View Tutorial          By: hisham at 2010-11-24 11:01:54

5. I have some questions : 1) Which type of GC used
View Tutorial          By: SP at 2013-06-04 15:48:59

6. nice one
View Tutorial          By: navyasri at 2012-05-02 04:41:10

7. Why this exception at run time?

Fri

View Tutorial          By: Sebin Joseph at 2011-04-01 06:03:17

8. its a good example
View Tutorial          By: Sonal at 2009-03-25 08:35:10

9. thanks for your tutorial, but how to us it?

View Tutorial          By: Desman Gea at 2014-07-18 16:54:41

10. what is the meaning of instantiated in abstract cl
View Tutorial          By: Manikandan MP at 2011-12-20 15:17:38