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. Can anybody tell.... what if condition is doing in
View Tutorial          By: Randhir Sambyal at 2013-08-26 06:37:25

2. Hi..
i a'm Sajid mestri (Maha,sangli)

View Tutorial          By: sajid at 2010-10-30 00:32:15

3. Excellent. I got stuck in a huge project and was f
View Tutorial          By: Rahul Tiwari at 2010-12-08 22:40:29

4. HI can you send send sms throgh java program above
View Tutorial          By: sasikumar at 2007-02-27 01:39:11

5. how to connect database simple method
View Tutorial          By: kavimozhian at 2013-04-08 11:14:29

6. Very Very nice explanation...
View Tutorial          By: anil at 2010-11-04 00:22:58

7. you can put the a loop for multiple extension
View Tutorial          By: Arun at 2012-12-07 05:23:47

8. Can u send total code, i am in critical position n
View Tutorial          By: ram at 2011-05-16 07:07:10

9. Thanx.. it helps me a lot, now.. i have 1 more que
View Tutorial          By: GuzZpaWn at 2012-01-15 17:19:29

10. Hi all this program is working very fine .... i ha
View Tutorial          By: Ashish at 2009-03-25 04:28:25