Insem OOP (2021)
Insem OOP (2021)
Instructions to Candidates:
❖ Answer ALL the questions
❖ Missing data may be suitable assumed
1 Explain multiple inheritances using an abstract class with respective syntax. Write a 4
suitable program to demonstrate the same using the following scenario:
Create a “Movie” class with two methods as “plot()” and “getName()”. Extend a
minimum of Five movies as different classes from the base class Movies and
redefined “plot()” and “getName()” as their methods. Display method overloading.
For every random number generated in the main class, the respective movie name
with the plot should be displayed. Show how super, this and final keywords are used.
2 Differentiate between compile time and runtime exception with respective examples. 4
Write a suitable program to demonstrate the same using the following scenario:
Design a Java program to search the name of a Student from a class. Assume an array
of 5 students with respective details (RegNo, FirstName, LastName, Course). When a
student has to be searched, his “FirstName” should be given as input and we search
using string manipulation. [Note: create a minimum 5 student objects as array
elements and handle “ArrayIndexOutOfBoundsException” and
“InputMismatchException”]
Create a “Mobile” class that holds 5 Mobile objects. The Mobile class shall take 5
attributes from the user as “modelID” (int), “ram” (int), “company_name” (String),
“isTouchScreen” (boolean) and “price” (double). Write two methods as
“mobileDetails()” and “mobilePrice()” to display details of mobile and price
associated with the mobileID. Show constructor overloading in passing parameters
to the above methods.
4 What are the differences between List and Set in Java? Write a suitable program to 3
demonstrate them using the following scenario:
The Class “Home” has a list “furniture” and a set “electricalAppliances” to store 10
string items of the home. If there is no item to enter, then collections will have “Null”
items. Class “Home” has methods “read”, “check” and “display” to do the
corresponding tasks. The method “check” throws “DuplicateItemFoundException”
when “furniture” and “electricalAppliances” have duplicate items in the collection.
Page 1 of 2
The class “MainClass” creates an array of “Home” objects to store items for 5 homes.
5 What would be your choice between interface and abstract class for the following 3
scenario. Give two reasons for your choice.
Write a suitable program to demonstrate the same using the following scenario: The
class “Bike” has “gearsCount” and “passengerCount”. The class “Car” has
“gearsCount” and “passengerCount”. The class “Vehicle” uses “Bike” and “Car” to
decide the vehicle detail entered is 2-Wheeler or 4-Wheeler in method “input”.
6 Write a program to read all lines from the file “sample.txt” in class “ReadLine” and 3
stores them in string “s1”. The method “process” searches for string “s2” and
replaces it with string “s3”. The updated string “s1” is stored in the file “updated.txt”
through method “fileUpdate”. The main class “MainClass” creates objects and calls
the methods to do tasks. Consider suitable exceptions in the program.
Page 2 of 2