ScCuWh
ScCuWh
3. Which access modifier allows access within the same class only?
A. Private
B. Protected
C. Public
D. Internal
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.