Dse2153 Oop QP (D3)
Dse2153 Oop QP (D3)
Instructions to Candidates:
❖ Answer ALL the questions
❖ Missing data may be suitable assumed
❖
1 How does the dynamic dispatch method overrides the method in multilevel inheritance 4
and what are the advantages of the same? Write a suitable program to demonstrate the
same using the following scenario:
Create a class “Literature” with two attributes as “title” and “author” and also a method
as “print()” to print the title and author details. Now extend two classes from Literature
class as “Book” and “Poem”. Let “Book” class hold attributes as “publisher”, “genre”,
“author” and “title” with a method “print()”. Let “Poem” class hold attributes like
“style”, “title”, “author” with a method “print()”. Now show how multiple inheritances
and dynamic method dispatch are possible for the above scenario. Show how super,
this and final keywords are used.
2 Define exception handling and list at least 6 common Java exceptions that are handled 4
by Java. Write a suitable program to demonstrate the exception handling using the
following scenario:
A program that accepts an integer between 1 and 12 to display the respective month.
Raise an Input Mismatch Exception. Also, if the user enters a value less than 1 and
more than 12, the program should raise an Array Index Out of Bounds Exception.
[Note: Use Date class to display the month]
Create a class “Polygone” and calculate the area of the square, rectangle, triangle,
equilateral triangle, and circle. Consider a switch case where the user can choose the
polygon of his/her choice and display the area of the polygon. Show constructor
overloading to pass the different parameters for the method “area()”.
4 What are the differences between List and Map in Java? Write a suitable program to 3
display the same using the following scenario:
The Class “College” has a list “courses” and a Map “subjects” to store only 10 string
entries. If there is no item, then collections will have “Null” items. Class “College” has
methods “input”, “compare” and “output” to do the corresponding tasks. The method
“Compare” throws “SimilarEntryFoundException” when “course” and “subjects” have
Page 1 of 2
duplicate items in the collection. The class “MainClass” creates an array of “College”
objects to store 10 entries.
5 How do interfaces benefit from the inheritances in Java programming? Write a suitable 3
program to demonstrate the same using the following scenario:
6 Write a program to read alternate characters from the file “exam.txt” in class 3
“CharProcess”. The method “alter” inserts the real number between the characters and
stores the string content in string “s1”. The method “storeFile” writes the charter
followed by even number into file “even.txt”. The main class “MainClass” creates
objects and calls the methods to do tasks. Consider suitable exceptions in the program.
Page 2 of 2