You are on page 1of 2

FOUNDATION UNIVERSITY

RAWALPINDI CAMPUS
FINAL EXAMINATION (FALL 2020)

Programme: BS Semester: 2
Course Title: Object Oriented Programming Sections: --
Instructor Name: Dr. Shariq Hussain, Dr. M. Ishtiaq, Dr. Imran Daud Max Marks: 25
Time Allowed: 3 Hour Date:

Registration no.
Name
Batch
Semester-Section

Instructions to read before starting the Exam:

World has become a global village and the means of Transportation have become inevitable. Two
most common transportation modes are air, and inland (road). For air travel mostly Airplanes are
used. Airplanes have specific properties, i.e. No. of engines, and Max Fuel Capacity. For road
travel Vehicles are used. Primarily, Passenger and Logistic vehicles are the most common types.
Two wheelers, Motorcycle and bicycle are also used for intra-city travel. The common features
among both these types are, Manufacturer name, Year of manufacture. The passenger vehicles
have an added attribute of passenger capacity while the logistic vehicles are classified according to
the loading capacity both as a weight and volume. Due to the rising cost of fuel, there is a need to
maximize the fuel efficiency of vehicles, which is measured in no. of kilo meters traveled per liter
fuel consumption.
In inheritance scenarios, usually the design starts from the most generic class containing the
attributes common among all the classes in the hierarchy. In this scenario, transport ID (for
example ABK-711 is assigned to the vehicles registered in Islamabad, Pakistan), this ID could be a
good candidate in the transport class. The access modifier for the transport ID must be private if
your second-name starting letter is between A-H, it must be public if letter is between I-Q and
protected if it is between letters R-Z (e.g., for name Muhammad Umar the access modifier will be
protected).
Also, identify other features/attributes of the transportation class and all other classes.

Page 1 of 2
a) (5 Marks)
From the given description identify the appropriate classes with its attributes/methods and
inheritance relationship. Design the inheritance diagram and draw it using MS Word/other
drawing tool. The design must include the details of the respective fields.
b) (10 Marks)
Write Java code to implement all the classes identified above. Define constructor, get and
set methods, with overridden toString() method for all the classes. The solution must
demonstrate the usage of following features of java programming:
i. Reuse the constructors of the same class or super class by a call using this()/super()
ii. Demonstrate the concept of upcasting/downcasting in your code in the polymorphic
implementation. Must use instanceof operator before converting to a target type.
iii. Use the concept of abstract classes by choosing appropriate classes to be abstract

You have to design a system where data of an airplane, a truck, a private car and a
motorcycle is to be maintained. Create an array (Polymorphic behavior) of suitable size to
contain these transportation machines.
c) (5 Marks)
Take input from the user about the objects data and store in the array and write the array
data to a file having the name, ‘TransportData_yourName_registrtionNumber.txt’. While
writing the data to a file, handle appropriate checked/unchecked exceptions. While
providing input to the program enter specification of your own transportation means used
throughout your life.

Page 2 of 2

You might also like