0% found this document useful (0 votes)
22 views1 page

Ostad Test

The document defines an abstract class 'Vehicle' with methods to set and get speed, and an abstract method 'move'. A 'Car' class extends 'Vehicle' and implements the 'move' method to print the car's speed. In the main function, a 'Car' object is created, its speed is set to 80, and the move method is called.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Ostad Test

The document defines an abstract class 'Vehicle' with methods to set and get speed, and an abstract method 'move'. A 'Car' class extends 'Vehicle' and implements the 'move' method to print the car's speed. In the main function, a 'Car' object is created, its speed is set to 80, and the move method is called.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

abstract class Vehicle {

int _speed = 0;

void move();

void setSpeed(int speed) {


_speed = speed;
}

int getSpeed() {
return _speed;
}
}

class Car extends Vehicle {


@override
void move() {
print("The car is moving at $_speed km/h");
}
}

void main() {
Car myCar = Car();
myCar.setSpeed(80);
myCar.move();
}

You might also like