016-001-001
Abstract Class: Vehicle Definition
Medium
Problem Description
abstract class: Vehicle Definition
In this problem, you will create a program that defines an abstract class Vehicle with an abstract method move(int speed), overrides it in both Car and Bike classes, and displays each vehicle's speed to standard output.
Learning Objective: Define common interface using abstract class and abstract methods
Create a vehicle abstract class. Define abstract methods and implement in Car and Bike.
Input
Line 1: Car speed (integer)
Line 2: Bike speed (integer)
Output
Car running at [speed] km/h
Bike running at [speed] km/h
Test Cases
※ Output examples follow programming industry standards
Input:
100 20
Expected Output:
Car running at 100 km/h Bike running at 20 km/h
Input:
0 0
Expected Output:
Car running at 0 km/h Bike running at 0 km/h
Input:
60 15
Expected Output:
Car running at 60 km/h Bike running at 15 km/h
Input:
-1 -1
Expected Output:
Car running at -1 km/h Bike running at -1 km/h
❌ Some tests failed
Your Solution
Current Mode:● My Code
Vehicle.java🔒
Car.java🔒
Bike.java🔒
Solution.java🔒
4/6 ファイル218B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
abstract class Vehicle {
}
0 B / 5 MB
You have 7 free executions remaining
