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. your web site is very useful for students
View Tutorial          By: aathithi at 2008-06-22 22:41:07

2. It is very help full to me and very simple underst
View Tutorial          By: Reddymalla Babu Sircilla at 2013-02-22 08:28:22

3. Hi thanks for the example for overriding toString(
View Tutorial          By: Reshma at 2011-05-11 10:46:08

4. I Want To Know More About Windows Azure Advantages
View Tutorial          By: sathish at 2010-08-31 10:23:10

5. Very nicely explained, especially the step-by-step
View Tutorial          By: Kaushik at 2012-09-20 06:58:45

6. could you plz tell me how to run this all programs
View Tutorial          By: abhishek at 2010-10-27 00:08:57

7. Sir , I am doing BCS . I want to know more about
View Tutorial          By: Sachin deshmukh at 2010-08-04 02:24:59

8. Once i run it gives the following error.Why "
View Tutorial          By: IDK at 2008-12-18 19:56:12

9. I Want more Advanced Case Shown...
I Know E

View Tutorial          By: Electron at 2009-11-23 02:32:07

10. How to find port names in pc? like COM1 etc ? i wn
View Tutorial          By: layiba at 2013-12-25 08:28:30