Question Bank: Practical No. 9 (Batch: A) JPR (TYIF) : College
Question Bank: Practical No. 9 (Batch: A) JPR (TYIF) : College
Question Bank: Practical No. 9 (Batch: A) JPR (TYIF) : College
9 (Batch: A) JPR(TYIF)
1. Declare a class ‘Student’ with data members ‘name’, ‘roll number’ and
‘marks’. Also declare a class ‘MyRecord’ which inherited from class
‘Student’. Display name, roll number and percentage by creating the object
of class ‘MyRecord’.
2. Create a base class to get two numbers from user in the base class and
one number from derived class. The derived class contains a method
‘dispMax()’, which displays maximum of three numbers, a method
‘dispMin()’ to display minimum of three numbers and method equality( )
which checks whether any two of these three numbers are equal or not.
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 branch along with college information.
College
– show( )
• name
• instt. code
Biscuit
• company
• name
Dealer
• product_name
• price
Retailer
• sell_price
– display( )
-1-
6. Create a class ‘TYIF’ which contain data members: total subjects, total
students. Inherit two classes ‘Test1’ and ‘Test2’ from it to have marks
from two different MSBTE class tests. Input the values for all data
members (including super class) of these classes and find average of both
the class tests.
7. Implement following inheritance for one object. Input whole data using
constructor of sub-class and display these data. Display capital of India
only.
India
• president
• capital
• GDP
Maharashtra
• governor
• capital
- display()
Word98
• year
• price
- display1( )
Word2000
• year
• price
- display2( )
Word2003
• year
• price
- display3( )
Word2007
• year
• price
- display4( )
-2-
C++
• developer
• year
- input( )
Java
• developer
• year
- input( )
10. Define a class ‘Human’ having data members name and gender. Create
classes ‘Woman’ and ‘Man’ derived from ‘Human’ having data member
age in both. Create objects of ‘Man’ and ‘Woman’ having a constructor
to initialize all data members (including super class) for both classes.
Define method find() in ‘Human’ to pass objects of ‘Man’ and ‘Woman’.
It will find who is elder.
11. Implement following inheritance. Display data for three employees and
display names of the employees having salary greater than 15000.
Person
• Name
• Age
Employee
• Designation
• Salary
- outPut()
12. Implement following inheritance. Create object of ‘Digital’ to use both the
methods in order to initialize all data members. Assume all values are in
‘double’. Display all the accepted values. Make use of ‘this’.
Analog
• frequency
- input( )
Digital
• impedance
• power
- accept( )
- displayAll( )
13. Implement following inheritance. Use only given methods to initialize all
the data values. Make the use of super to call constructors. Display all
values
-3-
VaccumTube
• power_dissp
- input( )
Transistor
• speed
LSI
• total transistors
- display( )
14. Implement following inheritance. Making the use of ‘super’ and ‘this’
initialize all the values by creating object of ‘Bangladesh’. Use displayAll()
to display values of all data members. Assume all String values.
India
• continent
• capital
Pakistan
• capital
• national_game
Bangladesh
• capital
- displayAll( )
Arabic
• script
• nation
Urdu
• city_name
Sindhi
- showThis( )
-4-
Mouse
• Speed
• company name
- initialize( )
TrackBall
• Speed
• company name
- displayAll( )
17. Implement following inheritance. Making the use of ‘T20’s object initialize
all the values and define appropriate methods to display all the values.
Test
• Over_per_inn
• time_in_hrs
OneDay
• Over_per_inn
• time_in_hrs
T20
• Over_per_inn
• time_in_hrs
18. Implement following inheritance. Make the use of ‘super’ and ‘this’ to
initialize and call constructors. Input and output whole data for one object.
GrandMother
• age
Mother
• age
• name
- input ( )
Son
• name
- accept ( )
-5-
OpticalDisc
• thickness
- whichIsBetter()
CompactDisc DigitalVersatileDisc
• capacity • capacity
• speed • speed
• price • price
20. Implement following inheritance. Create the objects of ‘USB’ and ‘SATA’
to input all these values and display those using appropriate methods. The
method ‘findCheaper()’ and ‘findFaster()’ accepts the objects of ‘USB’ and
‘SATA’ to find which interface is better by comparing in terms of price and
speed respectively.
Interface
• speed
• device
USB SATA
• price • price
- input( ) - accept( )
- findCheaper( ) - findFaster( )
-6-