KEMBAR78
Simple OOPs Problems Clean-1 | PDF
0% found this document useful (0 votes)
11 views1 page

Simple OOPs Problems Clean-1

Uploaded by

Vishwas U. K.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Simple OOPs Problems Clean-1

Uploaded by

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

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.

You might also like