Batch 25 and 26 Test Paper
Batch 25 and 26 Test Paper
______
1.Create a 'Vehicle' class with a method 'StartEngine'. Create 'Car' and 'Truck'
classes that inherit from 'Vehicle' and override 'StartEngine' method to output
"Car engine started" and "Truck engine started" respectively. Create an class
'Test' and create object for 'Car' and 'Truck' call the methods. (inheritance)
bool BookRoom()
bool CancelBooking()
Create an abstract class 'Room' implementing 'IRoomBooking':
Instance variables:
RoomType (string)
IsBooked (bool)
Constructor:
Checks if the room is not booked, sets 'IsBooked' to true, prints "Booked
successfully", and returns true. If already booked, prints "Already booked" and
returns false.
Checks if the room is booked, sets 'IsBooked' to false, prints "Booking canceled",
and returns true. If no booking found, prints "No booking found" and returns false.
Example Output:
2.Create an Interface called ‘ISim’ and write two abstract methods called
‘TalkTime() and Data()’ implement ISim interface in classes called ‘Airtel’, and
‘Jio’ and ‘BSNL’ . Create an object through which user can switch between one
network to another network using Dynamic Polymorphism.
void RentVehicle();
void ReturnVehicle();
Instance variables:
VehicleType (string)
IsRented (bool)
Constructor:
Accepts 'VehicleType' as a parameter.
Checks if the car is not rented, sets 'IsRented' to true, and prints "Car rented
successfully." If already rented, prints "Car is already rented."
Checks if the car is rented, sets 'IsRented' to false, and prints "Car returned
successfully." If not rented, prints "No car is currently rented."
2.Write a C# program to accept any two Numbers perform the arithmetic operations
using methods like Sum(),Difference(),Product(),Quotient() according to the user
choice using switch case. If user enter 1 then it should call Sum(), 2 then
Difference etc.
void CheckOut();
void Return();
Instance variables:
ResourceType (string)
IsCheckedOut (bool)
Constructor:
Accepts ResourceType as a parameter.
Checks if the book is not checked out, sets 'IsCheckedOut' to true, and prints
"Book checked out successfully." If already checked out, prints "Book is already
checked out."
Checks if the book is checked out, sets 'IsCheckedOut' to false, and prints "Book
returned successfully." If not checked out, prints "No Book is currently checked
out."
Example Output:
"Book checked out successfully."
"DVD returned successfully."