0% found this document useful (0 votes)
59 views

OOP Assignments Practicals

This document provides 50 practice questions on object-oriented programming (OOP) concepts ranging from beginner to expert level. The questions involve creating classes with attributes and methods to represent real-world entities like rectangles, circles, bank accounts, employees and more. More advanced questions involve inheritance, polymorphism and adding additional functionality like string representations. The goal is to help readers better understand and practice OOP concepts.

Uploaded by

Yagnesh Vyas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

OOP Assignments Practicals

This document provides 50 practice questions on object-oriented programming (OOP) concepts ranging from beginner to expert level. The questions involve creating classes with attributes and methods to represent real-world entities like rectangles, circles, bank accounts, employees and more. More advanced questions involve inheritance, polymorphism and adding additional functionality like string representations. The goal is to help readers better understand and practice OOP concepts.

Uploaded by

Yagnesh Vyas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

HTTPS://WWW.LINKEDIN.

COM/IN/NIBEDITA-SARKAR-A0451725B/

Object Oriented Programming


Language(OOP)
50 Coding Questions for Practice

Nibedita Sarkar
5/8/2023

Here are 50 practice questions from beginner to advanced level that will help you understand
Object-Oriented Programming (OOP) language better.
50 practice questions on classes and objects from
beginner to advanced level

Beginner Level:

1) Create a class named "Person" with a "name" attribute and a "greet()" method that
prints "Hello, my name is [name]".
2) Create a class named "Rectangle" with "width" and "height" attributes and a
"get_area()" method that returns the area of the rectangle.
3) Create a class named "Circle" with a "radius" attribute and a "get_area()" method that
returns the area of the circle.
4) Create a class named "Student" with "name" and "age" attributes and a
"display_student()" method that prints the name and age of the student.
5) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods.

Intermediate Level:

6) Create a class named "Animal" with "name" and "species" attributes and a
"make_sound()" method that prints the sound the animal makes.
7) Create a class named "Car" with "make" and "model" attributes and a "start_engine()"
method that prints "The [make] [model] is starting".
8) Create a class named "Employee" with "name" and "salary" attributes and a "get_tax()"
method that calculates and returns the tax amount for the employee.
9) Create a class named "Person" with "name" and "address" attributes and a
"display_details()" method that prints the name and address of the person.
10) Create a class named "Book" with "title", "author", and "year" attributes and a
"display_book()" method that prints the title, author, and year of the book.
Advanced Level:

11) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods, and add a "transaction_history" attribute to keep track of all
transactions.
12) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods.
13) Create a class named "Person" with "name" and "age" attributes, and create a subclass
"Employee" with "salary" attribute and a "display_employee()" method that prints the
name, age, and salary of the employee.
14) Create a class named "Fraction" with "numerator" and "denominator" attributes and
methods for addition, subtraction, multiplication, and division of fractions.
15) Create a class named "Triangle" with "base" and "height" attributes and a "get_area()"
method that returns the area of the triangle.

Expert Level:

16) Create a class named "Animal" with "name" and "species" attributes and a
"make_sound()" method that prints the sound the animal makes. Create a subclass
"Dog" with a "breed" attribute and a "bark()" method that prints "Woof!".
17) Create a class named "Rectangle" with "width" and "height" attributes and a
"get_area()" method that returns the area of the rectangle. Add a "str()" method to
print the dimensions of the rectangle.
18) Create a class named "Person" with "name" and "age" attributes, and create a subclass
"Student" with "grade" attribute and a "display_student()" method that prints the
name, age, and grade of the student.
19) Create a class named "Car" with "make" and "model" attributes and a "start_engine()"
method that prints "The [make] [model] is starting". Add a "str()" method.
20) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods, and add a "str()" method to print the balance of the account.
21) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods. Add a "str()" method to print
the dimensions of the shape.
22) Create a class named "Person" with "name" and "age" attributes, and create a subclass
"Employee" with "salary" attribute and a "display_employee()" method that prints the
name, age, salary, and employee ID of the employee.
23) Create a class named "Fraction" with "numerator" and "denominator" attributes and
methods for addition, subtraction, multiplication, and division of fractions. Add a "str()"
method to print the fraction in the form "numerator/denominator".
24) Create a class named "Triangle" with "base" and "height" attributes and a "get_area()"
method that returns the area of the triangle. Add a "str()" method to print the
dimensions of the triangle.

Advanced Expert Level:

25) Create a class named "Animal" with "name" and "species" attributes and a
"make_sound()" method that prints the sound the animal makes. Create subclasses
"Dog", "Cat", and "Cow" with their own "make_sound()" methods.
26) Create a class named "Rectangle" with "width" and "height" attributes and a
"get_area()" method that returns the area of the rectangle. Add a "get_perimeter()"
method that returns the perimeter of the rectangle.
27) Create a class named "Person" with "name" and "age" attributes, and create a subclass
"Student" with "grade" attribute and a "display_student()" method that prints the
name, age, grade, and student ID of the student.
28) Create a class named "Car" with "make" and "model" attributes and a "start_engine()"
method that prints "The [make] [model] is starting". Add a "stop_engine()" method that
prints "The [make] [model] is stopping".
29) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods, and add a "get_interest()" method that calculates and returns
the interest earned on the account.
30) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods. Add a "perimeter()" method
to calculate and return the perimeter of the shape.
Expert Plus Level:

31) Create a class named "Animal" with "name" and "species" attributes and a
"make_sound()" method that prints the sound the animal makes. Create subclasses
"Dog", "Cat", and "Cow" with their own "make_sound()" methods. Add a "str()" method
to print the name and species of the animal.
32) Create a class named "Rectangle" with "width" and "height" attributes and a
"get_area()" method that returns the area of the rectangle. Add a "get_perimeter()"
method that returns the perimeter of the rectangle. Add a "str()" method to print the
dimensions and area of the rectangle.
33) Create a class named "Person" with "name" and "age" attributes, and create a subclass
"Employee" with "salary" attribute and a "display_employee()" method that prints the
name, age, salary, employee ID, and department of the employee.
34) Create a class named "Car" with "make", "model", and "year" attributes and a
"start_engine()" method that prints "The [year] [make] [model] is starting". Add a
"stop_engine()" method that prints "The [year] [make] [model] is stopping". Add a
"str()" method to print the make, model, and year of the car.
35) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Create another subclass "CheckingAccount" with a
"minimum_balance" attribute and a "check_minimum_balance()" method that checks if
the account balance is above the minimum balance.
36) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods. Add a "perimeter()" method
to calculate and return the perimeter of the shape. Add a "str()" method to print the
dimensions, area, and perimeter of the shape.
37) Create a class named "Employee" with "name", "age", and "salary" attributes and a
"display_employee()" method that prints the name, age, salary, and employee ID of the
employee. Create a subclass "Manager" with a "department" attribute and a
"display_manager()" method that prints the name, age, salary, employee ID, and
department of the manager.
38) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Create another subclass "CheckingAccount" with a
"minimum_balance" attribute and a "check_minimum_balance()" method that checks if
the account balance is above the minimum balance. Add a "str()" method to print the
balance, interest rate, and minimum balance of the account.
39) Create a class named "Vehicle" with "make", "model", and "year" attributes and a
"start_engine()" method that prints "The [year] [make] [model] is starting". Add a
"stop_engine()" method that prints "The [year] [make] [model] is stopping". Create
subclasses "Car" and "Truck" with their own "start_engine()" and "stop_engine()"
methods that print more specific messages. Add a "str()" method to print the make,
model, and year of the vehicle.
40) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods. Add a "perimeter()" method
to calculate and return the perimeter of the shape. Add a "draw()" method to draw the
shape on the screen using ASCII art.
41) Create a class named "Employee" with "name", "age", and "salary" attributes and a
"display_employee()" method that prints the name, age, salary, and employee ID of the
employee. Add a "change_salary()" method that changes the employee's salary by a
specified percentage. Create a subclass "Manager" with a "department" attribute and a
"display_manager()" method that prints the name, age, salary, employee ID, and
department of the manager. Add a "change_department()" method that changes the
manager's department.
42) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Add a "compound_interest()" method that compounds the
interest earned over a specified number of years. Create another subclass
"CheckingAccount" with a "minimum_balance" attribute and a
"check_minimum_balance()" method that checks if the account balance is above the
minimum balance. Add a "charge_overdraft_fee()" method that charges a fee if the
account is overdrawn.
43) Create a class named "Vehicle" with "make", "model", and "year" attributes and a
"start_engine()" method that prints "The [year] [make] [model] is starting". Add a
"stop_engine()" method that prints "The [year] [make] [model] is stopping". Create
subclasses "Car" and "Truck" with their own "start_engine()" and "stop_engine()"
methods that print more specific messages. Add an "accelerate()" method that
increases the speed of the vehicle by a specified amount. Add a "brake()" method that
decreases the speed of the vehicle by a specified amount. Add a "str()" method to print
the make, model, year, and speed of the vehicle.
44) Create a class named "Shape" with an "area()" method, and create subclasses
"Rectangle" and "Circle" with their own "area()" methods. Add a "perimeter()" method
to calculate and return the perimeter of the shape. Add a "draw()" method to draw the
shape on the screen using ASCII art. Add a "resize()" method that resizes the shape by a
specified factor. Add a "str()" method to print the dimensions, area, perimeter, and
ASCII art of the shape.
45) Create a class named "Person" with "name" and "age" attributes and a "talk()" method
that prints "Hello, my name is [name] and I am [age] years old". Create a subclass
"Teacher" with a "subject" attribute and a "teach()" method that prints "I am teaching
[subject]". Create another subclass "Student" with a "major" attribute and a "learn()"
method that prints "I am learning [major]". Add a "str()" method to print the name, age,
and role of the person.
46) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Add a "compound_interest()" method that compounds the
interest earned over a specified number of years. Create another subclass
"CheckingAccount" with a "minimum_balance" attribute and a
"check_minimum_balance()" method that checks if the account balance is above the
minimum balance. Add a "transfer()" method that transfers money from one account to
another.
47) Create a class named "Animal" with "name and "species" attributes and a
"make_sound()" method that prints the sound the animal makes. Create subclasses
"Dog" and "Cat" with their own "make_sound()" methods that print the sound of a dog
barking and a cat meowing, respectively. Add a "walk()" method that prints the animal is
walking. Add a "str()" method to print the name, species, and sound of the animal.
48) 48. Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Add a "compound_interest()" method that compounds the
interest earned over a specified number of years. Create another subclass
"CheckingAccount" with a "minimum_balance" attribute and a
"check_minimum_balance()" method that checks if the account balance is above the
minimum balance. Add a "charge_monthly_fee()" method that charges a fee if the
account is below the minimum balance.
49) Create a class named "Rectangle" with "length" and "width" attributes and an "area()"
method that calculates and returns the area of the rectangle. Add a "perimeter()"
method that calculates and returns the perimeter of the rectangle. Create a subclass
"Square" with a "side_length" attribute and override the "area()" and "perimeter()"
methods to calculate the area and perimeter of a square instead of a rectangle. Add a
"resize()" method that resizes the rectangle or square by a specified factor. Add a "str()"
method to print the dimensions, area, and perimeter of the rectangle or square.
50) Create a class named "BankAccount" with "balance" attribute and "deposit()" and
"withdraw()" methods. Create a subclass "SavingsAccount" with a "interest_rate"
attribute and a "calculate_interest()" method that calculates and returns the interest
earned on the account. Add a "compound_interest()" method that compounds the
interest earned over a specified number of years. Create another subclass
"CheckingAccount" with a "minimum_balance" attribute and a
"check_minimum_balance()" method that checks if the account balance is above the
minimum balance. Add a "transfer()" method that transfers money from one account to
another. Create another subclass "InvestmentAccount" with a "risk_level" attribute and
a "calculate_return()" method that calculates and returns the expected return on the
investment based on the risk level. Add a "sell()" method that sells the investment and
adds the return to the account balance.

You might also like