0% found this document useful (0 votes)
10 views4 pages

Batch 25 and 26 Test Paper

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)
10 views4 pages

Batch 25 and 26 Test Paper

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/ 4

Set-A

______
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)

2.Create two interfaces called ‘IInternalMarks’ and ‘IExternalMarks’ and write an


abstract method StudentInternalMarks() in IInternalMarks and StudentExternalMarks()
in IExternalMarks. Finally create a class called ‘StudentResult’ which implements
both the Interfaces and display the total marks (internal marks + external marks)
in DisplayResult() method in StudentResult class

3.Create an interface 'IRoomBooking' with the following methods:

bool BookRoom()
bool CancelBooking()
Create an abstract class 'Room' implementing 'IRoomBooking':

Instance variables:

RoomType (string)
IsBooked (bool)
Constructor:

Accepts 'RoomType' as a parameter.


Abstract methods implemented like abstract methods:

public abstract bool BookRoom()


public abstract bool CancelBooking()

Create classes 'StandardRoom','DeluxeRoom' and 'Suite' inheriting 'Room' class:

Override the BookRoom() method:

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.

Override the CancelBooking() method:

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.

Create class 'Test':

Main method to test the classes:

Creates instances of 'StandardRoom', 'DeluxeRoom', and 'Suite'.


Calls BookRoom() and CancelBooking() methods on each instance.
Prints messages confirming booking or cancellation including the room type.

Example Output:

"Deluxe room booking confirmed."


"Suite room booking canceled."
Set-B
______
1.Create a abstract 'Shape' class with a abstract method 'Draw' Create 'Circle' and
'Rectangle' classes that inherit from 'Shape' and override 'Draw' method to output
"Drawing a Circle" and "Drawing a Rectangle" respectively. Create an class 'Test'
and create object for 'Circle' and 'Rectangle' call the methods.(Abstraction)

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.

3.Create an interface 'IVehicleRental' with the following methods:

void RentVehicle();
void ReturnVehicle();

Create an abstract class 'Vehicle' implementing 'IVehicleRental':

Instance variables:

VehicleType (string)
IsRented (bool)

Constructor:
Accepts 'VehicleType' as a parameter.

Abstract methods implemented like abstract methods:

public abstract void RentVehicle();


public abstract void ReturnVehicle();

Create classes 'Car','Truck' and 'Motorcycle' inheriting from Vehicle:

Override the RentVehicle() method:

Checks if the car is not rented, sets 'IsRented' to true, and prints "Car rented
successfully." If already rented, prints "Car is already rented."

Override the ReturnVehicle() method:

Checks if the car is rented, sets 'IsRented' to false, and prints "Car returned
successfully." If not rented, prints "No car is currently rented."

Create class 'Test':

Main method to test the classes:

Creates instances of 'Car', 'Truck', and 'Motorcycle'.


Calls RentVehicle() and ReturnVehicle() methods on each instance.
Prints messages confirming rental or return status including the vehicle type.
Example Output:

"Car rented successfully."


"Truck returned successfully."
Set-C:
______
1.Create a 'Person' class with private attributes 'name' and 'age' and public
methods 'SetName' and SetAge' to set the attributes. Add a method 'Display' to
display the 'name' and 'age' {encapsulation}

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.

3.Create an interface 'ILibraryResource' with the following methods:

void CheckOut();
void Return();

Create an abstract class 'LibraryResource' implementing 'ILibraryResource':

Instance variables:

ResourceType (string)
IsCheckedOut (bool)

Constructor:
Accepts ResourceType as a parameter.

Abstract methods implemented like abstract methods:

public abstract void CheckOut();


public abstract void Return();

Create class 'Book','Magazine' and 'DVD' inheriting from 'LibraryResource':

Override the CheckOut() method:

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."

Override the Return() method:

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."

Create class 'Test':

Main method to test the classes:

Creates instances of 'Book', 'Magazine', and 'DVD'.


Calls 'CheckOut()' and 'Return()' methods on each instance.
Prints messages confirming check-out or return status including the resource type.

Example Output:
"Book checked out successfully."
"DVD returned successfully."

You might also like