4 (Batch: A) JPR(TYIF)
1. Declare a class ‘student’ with data members ‘name’ and ‘roll number’. Also
declare a class ‘Record’ which inherits class ‘student’. Display name and roll
number with address by creating the object of class ‘Record’.
2. Create a base class to get two numbers from user in the base class. The
derived class contains a method ‘dispMax()’. Which displays maximum of
two numbers and a method ‘dispMin()’ to display minimum of two
numbers. Use constructors.
3. Implement the inheritance shown in figure below. The rectangle represents
the classes. The ‘•’ represents data members and ‘–‘ represents methods.
Display information of each class.
Goods
– display( )
• description
• price
Medicine
• company
• name
Dealer
• product_name
• price
Retailer
• sell_price
– display( )
-1-
Dimension
• Length
• Width
• Height
BookShelf
• no_of_shelves
- area()
- display()
Student
• Roll_no
• Name
• class
Exam
• sub_name
- display()
Student
• Roll_no
• Name
• class
Library
• sub_name
- display()
10. Define a class ‘Person’ having data members name, age and gender.
Create class ‘Student’ derived from ‘Person’ having data members
roll_number and name. Crete object of ‘Person’ having a constructor to
initialize all data members of both classes. Display whole data using
method ‘show()’.
11. Implement following inheritance. Display data for three employees and
display names of the employees having salary greater than 5000.
-2-
Person
• Name
• Age
Employee
• Designation
• Salary
- show()
Furniture
• Material
• Price
- input( )
Table
• Height
- accept( )
- display( )
13. Implement following inheritance. Assume suitable methods. Make the use
of super to call constructors.
Student
• Class
• Roll_number
- input( )
Test
• marks1
• marks2
• marks3
- enter( )
Result
• total
- display( )
14. Implement following inheritance. Assume suitable methods. Make the use
of super to call constructors.
-3-
Product
• product_id
• name
- initialize( )
Edibles
• weight
• price
• flavor
- enter( )
Display
- displayAll( )
C
• Structure
• Array
- input( )
C++
• Inheritance
• Overloading
Java
• Interface
- enter( )
- display( )
16. Implement following inheritance. Make the use of super to initialize and call
constructors.
Sanskrit
• Script (String)
- input( )
Marathi
• Literature (int)
- displayAll( )
17. Implement following inheritance. Make the use of super and this to
initialize and call constructors.
-4-
Galaxy
• name
- accept( )
MilkyWay
• name
• total stars
- displayAll( )
18. Implement following inheritance. Make the use of ‘super’ and ‘this’ to
initialize and call constructors.
GrandFather
• age
Father
• age
- input ( )
Daughter
• name
- accept ( )
19. Implement following inheritance. Make the use of ‘super’ and ‘this’ to
initialize and call constructors. Initialize one object’s values and find total
hours in the year.
Day
• total hours
Month
• total days
Year
• total months
- initialize ( )
- calHours( )
20. Implement following inheritance. Make the use of ‘super’ and ‘this’ to
initialize and call constructors. Initialize one object’s values and find total
hours in the year.
Computer
Electronics • Enhancements
• Inventions • Innovations
• Identifications - inputAll( )
• Justifications - addAll( )
-5-