-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ2.5.txt
44 lines (35 loc) · 976 Bytes
/
Q2.5.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public class TestCar{
public static void main(String args[]){
SportCar sc = new SportCar();
sc.drive();
sc.airballontype();
sc.display();
}
}
--------------------------------Car.java------------------------
public class Car {
private int speed;
private int noofgear;
void drive(){
speed = 300;
noofgear = 5;
}
void display(){
System.out.println("Speed of car is "+speed+" KMPH");
System.out.println("No of gears are "+noofgear);
}
}
-------------------------------SportCar.java------------------------
class SportCar extends Car{
private int initspeed;
private int gearstatus;
public void airballontype(){
initspeed=100;
gearstatus = 3;
}
void display(){
super.display();
System.out.println("Starting speed of car is "+initspeed);
System.out.println("No of gears are "+gearstatus);
}
}