Simple OOPs Concepts - Problem Statements
1. Class and Object
Create a class Pen with attributes brand and color. Create two objects of the class and print the brand and color for each
pen.
2. Constructor (__init__)
Create a class Laptop that uses a constructor to accept brand and price as inputs. Print the laptop's details using a
method called show_details().
6. Inheritance
Create a class Vehicle with an attribute brand. Create another class Car that inherits from Vehicle and adds an attribute
model. Display both brand and model using a method.
8. Encapsulation (Private Variable)
Create a class BankAccount with a private variable __balance. Provide methods to deposit(amount) and get_balance()
to safely access and modify the balance.
9. Polymorphism (Different Classes, Same Method Name)
Create two classes: Dog and Cat. Each should have a method speak() that prints 'Bark' or 'Meow'. Write a function that
calls speak() for any object passed to it.