2025 Pre-Board examination question paper set for Object Oriented Programming in Java.

Tribhuvan University
Faculty of Humanities & Social Sciences
OFFICE OF THE DEAN
2025
Bachelor in Computer Applications

Paper detail Value
Course Object Oriented Programming in Java
Code No. CACS204
Semester IIIrd
Full marks 60
Pass marks 24
Time 3 hours

Candidates are required to answer the questions in their own words as far as possible.

2. Create a method inside a class that takes an array of string as parameter and returns true if lengths of length of every string inside it is even and returns false otherwise. Create object of that class and call the method in main method and print the result.

3. What is thread life cycle? Write a program to demonstrate multithreading by creating thread using Runnable interface.

4. Differentiate between throw and throws keyword in Java. Write a program to demonstrate custom event handling in Java.

5. How can you create menu and submenu in swing? Write a suitable program to create a frame with menus and submenus.

6. Write a Java program to create a base class Vehicle with attributes brand, speed, and type, and a method called describe() that prints out its brand and type. Inherit the class in Car and Bike classes and override the describe() method to print specific messages for each vehicle.

7. How can we use listener interface to handle events? Write a program to demonstrate the handling of button click event.

8. How byte stream and character stream are different? Write a Java program to read the contents of one image file and write to another image file.

9. How static polymorphism and runtime polymorphism is different? Write a program considering following scenario: You are to develop a Payment Processing System for an e-commerce platform that can handle various payment methods, including Credit Card, PayPal, and Bank Transfer. Although each method processes transactions uniquely, they all share a common processPayment operation. To achieve this, you must define an interface named IPaymentMethod containing a single method, processPayment(double amount). Subsequently, create three distinct classes—CreditCardPayment, PayPalPayment, and BankTransferPayment—each of which will implement the IPaymentMethod interface and provide its specific implementation of the processPayment method; for example, CreditCardPayment should indicate it's "Processing credit card payment of Rs. [amount]...", PayPalPayment should state it's "Initiating PayPal transaction for Rs. [amount]...", and BankTransferPayment should confirm it's "Processing bank transfer for Rs. [amount]...". Finally, within your main() method, you will demonstrate runtime polymorphism: based on user input (e.g., selecting 1 for Credit Card, 2 for PayPal, or 3 for Bank Transfer), an IPaymentMethod reference will dynamically point to the chosen payment object, and its processPayment method will be invoked for a given transaction amount, simulating how an e-commerce system adapts to different payment methods.

10. How adapter class and listener interface are different? Explain the steps to connect and access database table using JDBC. Write a program using JDBC to insert a record into a database table and display all the record of that table in console. (Make your own assumption about database server, database and table structure).

11. Explain about any two layout managers in GUI development using swing with suitable programming example for each. Write a program to take name and phone number values from a swing frame and store the values in a database table when save button of that GUI is clicked. (Make your own assumption about database server and database).