0% found this document useful (0 votes)
14 views6 pages

ScCuWh

Uploaded by

wajihaa726
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

ScCuWh

Uploaded by

wajihaa726
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

MCQS(object oriented programming)

1. Which of the following is NOT a principle of OOP?


 A. Encapsulation
 B. Polymorphism
 C. Overloading
 D. Iteration

2. What does encapsulation mean in C#?


 A. Wrapping code and data into a single unit
 B. Restricting direct access to data fields
 C. Achieving runtime polymorphism
 D. Overriding base class methods

3. Which access modifier allows access within the same class only?
 A. Private
 B. Protected
 C. Public
 D. Internal

4. What is polymorphism in OOP?


 A. The ability to perform a single action in different ways
 B. The process of hiding implementation details
 C. Reusing code through inheritance
 D. Wrapping data and methods into a class

5. Which keyword is used to inherit a class in C#?


 A. inherit
 B. base
 C. extends
 D. : (colon)

6. What is the default access modifier for class members in C#?


 A. Public
 B. Private
 C. Protected
 D. Internal

7. Which of the following supports method overloading in C#?


 A. Methods with the same name but different return types
 B. Methods with the same name but different parameters
 C. Methods with the same name and parameters but in different classes
 D. Methods with the same name in derived classes

8. What does the virtual keyword in C# indicate?


 A. The method is sealed
 B. The method can be overridden in a derived class
 C. The method cannot be inherited
 D. The method is abstract

9. What is the purpose of the base keyword in C#?


 A. To create a new class
 B. To refer to the base class constructor or methods
 C. To define an abstract method
 D. To override a method
10. Which of the following is true about constructors in C#?
 A. Constructors can have a return type
 B. A class can have multiple constructors with the same signature
 C. A constructor initializes the object of a class
 D. Constructors cannot be overloaded

11. Which of the following is NOT an OOP concept?


 A. Inheritance
 B. Abstraction
 C. Multithreading
 D. Polymorphism

12. Which of the following best describes an abstract class in C#?


 A. A class that cannot have fields
 B. A class that cannot be inherited
 C. A class that can have both abstract and non-abstract methods
 D. A class that cannot have a constructor

13. What is the purpose of an interface in C#?


 A. To implement multiple inheritance
 B. To define a contract that derived classes must follow
 C. To encapsulate data
 D. To provide private methods to a class

14. What is method overriding?


 A. A method with the same name in different classes but with different parameters
 B. A method in a derived class that replaces a base class method
 C. A method that has multiple versions in the same class
 D. A method declared using the sealed keyword

15. Which of the following statements is true about the sealed keyword in C#?
 A. It prevents inheritance from a class
 B. It allows a method to be overridden
 C. It hides methods in a base class
 D. It indicates an abstract method
Practical Questions
Scenario 1: Online Shopping System
A shopping system has Product, Customer, and Order classes. Products have properties
like Name, Price, and Stock. Customers can place orders for products, which reduce the stock
quantity.
Questions
1. Create a Product class with properties Name, Price, and Stock. Add a
method IsInStock that checks if the stock is greater than zero.
2. Create a Customer class with properties Name and Email.
3. Create an Order class with properties OrderId, Customer, and a list of Products. Add a
method CalculateTotal to compute the total order value.
4. Write a program to simulate an order where a customer buys a product, ensuring the
stock is updated correctly after the purchase.

Scenario 2: Library Management System


A library management system involves Book, Member, and Loan classes. Members can borrow
books, and each loan tracks the LoanDate and DueDate.
Questions
1. Design a Book class with properties Title, Author, ISBN, and IsAvailable. Add methods to
mark a book as borrowed or returned.
2. Create a Member class with properties Name, MemberId, and a list of borrowed books.
3. Create a Loan class with properties Book, Member, LoanDate, and DueDate. Add a
method to calculate the number of overdue days.
4. Simulate a scenario where a member borrows a book and then returns it after the due
date. Calculate the overdue days.

Scenario 3: Vehicle Rental System


A vehicle rental system has Vehicle, Customer, and Rental classes. Each rental records the
vehicle, customer, rental period, and total cost.
Questions
1. Create a base class Vehicle with properties Make, Model, and RentalPricePerDay. Create
derived classes Car and Bike, each with additional properties.
2. Design a Customer class with properties Name and DrivingLicenseNumber.
3. Create a Rental class with properties Vehicle, Customer, RentalStartDate,
and RentalEndDate. Add a method to calculate the total rental cost.
4. Write a program where a customer rents a car for 5 days. Display the rental details and
calculate the total cost.

You might also like