Object Oriented Programming
SWE · Quiz · Summer 26
Paper 4 of 6By Md. Mehedi Hasan (2)Switch
Paper 4 of 6
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Daffodil International University
Faculty of Science & Information Technology
Department of Software Engineering
Course Code: SE216; Course Title: Object Oriented Programming
Time: 40 Mins Marks: 15
1. a) Considering following instructions, write java code. [8]
1. Create an interface Borrowable with one abstract method: borrow().
2. Create another interface Returnable with one abstract method: returnItem().
3. Create an interface LibraryService that extends both Borrowable and Returnable, and adds one abstract method: reserve().
4. Create an abstract class LibraryItem that implements LibraryService. It should contain two abstract methods, open() and close(), and one concrete method, displayInfo().
5. Create two subclasses, Book and Magazine, that extend LibraryItem and provide implementations for all necessary methods.
6. Override the displayInfo() method in both subclasses to display appropriate messages for each type of library item.
7. In a class named TesterClass, create objects of both Book and Magazine.
8. Invoke every available method on each object and display an appropriate message for each method call.
Output
Book is opening
Book is borrowed
Book is reserved
Book is returned
Book information is displayed
Book is closing
Magazine is opening
Magazine is borrowed
Magazine is reserved
Magazine is returned
Magazine information is displayed
Magazine is closing
b) Create a Java class named EventManager to manage participants for a University Photography Exhibition using ArrayList<String>. Perform the following 7 tasks in the given order: [7]
1. Create two ArrayList<String> objects named morningParticipants and eveningParticipants. Add the following participants:
- Morning: Asif, Nabila, Rohan, Tisha
- Evening: Sami, Nabila, Fahim, Zara
2. Create another ArrayList<String> named participants and use addAll() to combine both lists. Display the complete list and its size.
3. Check whether Tisha and Zara are present in participants. Display their positions if they exist; otherwise, display "Participant not found."
4. Find and display the first and last occurrence of Nabila in the combined list.
5. Replace Fahim with Hasan, then insert Maya at the third position. Display the updated list.
6. Use removeAll() to remove all participants from the eveningParticipants list from participants. Display the remaining participants and their total number.
7. Finally, use clear() to remove all remaining participants. Use isEmpty() to verify the list and display:
- "The participant list is empty."
- or "The participant list is not empty."