-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
32 lines (24 loc) · 658 Bytes
/
Copy pathCar.java
File metadata and controls
32 lines (24 loc) · 658 Bytes
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
class Car{
String brand = "Toyota";
String color = "white";
void drive(){
System.out.println("The car is driving.");
}
}
class NormalCar extends Car{
static int maxSpeed = 130;
}
class RaceCar extends Car{
static int maxSpeed = 200;
}
public class Main{
public static void main(String[] args) {
NormalCar normalCar = new NormalCar();
NormalCar.maxSpeed = 140;
NormalCar normalCar2 = new NormalCar();
System.out.println(NormalCar.maxSpeed);
System.out.println(NormalCar.maxSpeed);
RaceCar raceCar = new RaceCar();
System.out.println(RaceCar.maxSpeed);
}
}