Mid-Term examination question paper set for Advanced Java Programming from the year 2025.
Tribhuvan University
Faculty of Humanities & Social Sciences
OFFICE OF THE DEAN
2026
Bachelor in Computer Applications
| Paper detail | Value |
|---|---|
| Course | Advanced Java Programming |
| Code No. | CACS354 |
| Semester | VIth |
| Full marks | 60 |
| Pass marks | 24 |
| Time | 3 hours |
Candidates are required to answer the questions in their own words as far as possible.
Group B
2. Write a program to take a string from user and display whether the length of the string is even or odd.
3. How for loop and for-each loop in Java is different? Write a program having an array of 6 floating point numbers and display all the elements of the array using for-each loop.
4. Why constructors are used in a class? Write a program to demonstrate parameterized constructor.
5. What is method overloading? Write a program having a class AreaCalculator with overloaded methods named area() to compute the area of: a circle (given radius), a rectangle (given length and breadth) and a square (given side length).
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. Compare between concrete class, abstract class and interface in Java.
8. Explain about exception and exception handling in Java with the list of associated keywords.
Group C
9. How static polymorphism and runtime polymorphism is different? Write a program considering following scenario: You are tasked with developing a simple Ride Booking System that allows users to choose between different types of rides, such as a Bike, Car, or Scooter. Each ride type charges a different fare per kilometer: Rs. 16/km for Bike, Rs. 55/km for Car, and Rs. 14/km for Scooter. To implement this, define an interface named IRide that contains a method calculateFare(double distance). Then, create three classes—Bike, Car, and Scooter each of them should implement the IRide interface and provide their own implementation of the calculateFare method. In your main() method of main class, demonstrate runtime polymorphism by using a IRide reference to point to different ride types based on the user's input, and calculate the fare for a given distance.
10. Explain the use of try, multiple catch and finally blocks with suitable programming example.