OOPs Concepts (Hands-on 2)
[email protected]
+91-7022374614
US: 1-800-216-8930 (Toll-Free)
Problem Statement:
You work in XYZ Corporation as a Data Analyst. Your corporation has told you to work with the
inheritance of the classes.
Tasks to be performed:
1. Create a class named parent_Class and inside the class, initialize a global variable num as
10.
a. Create another class named child_Class and this class should be inherited from the
parent class.
b. Now create an object for the child_Class and with the help of child_Class object,
display the value of ‘num’.
2. Create three classes named A, B, and C.
a. Inside the A class, create a constructor. Inside the constructor, initialize 2 global
variables- name and age.
b. After initializing the global variables inside the constructor, now create a function
named
‘details’ and that function should return the ‘name’ variable.
c. Inside the B class, create a constructor. Inside the constructor, initialize 2 global
variables-
name and id.
d. After initializing the global variables inside the constructor, now create a function
named ‘details’ and that function should return the ‘name’ variable.
e. The C class should inherit from class A, and B. Inside the class C, create a
constructor, and inside the constructor, call the constructor of class A.
f. Now, create a method inside the class C, as get_details, and this function should
return the value of a name.
g. Atlast, create an object of class C, and with the help of the object, call the
get_details().
3. Create a class named Employee, with a constructor ‘__init__’ method that accepts name and
salary as parameters and set properties named name and salary.
4. Define __str__ method in Employee class so that when someone tries to print the object the
string Name: employee_name, Salary: employee_salary is printed with the actual employee
name and salary.
5. Create a program using classes and objects to implement the following:
1. A singly linked list, and various CRUD operations on the same.
2. A binary tree, and various CRUD operations on the same.
3. A graph data structure, and various CRUD operations on the same.
4. Implementation of Circular and Doubly linked lists.