CACS204 Object Oriented Programming in Java

Object Oriented Programming in Java TU Board 2026 question paper

20 questionsSit this paper (timed)

Tribhuvan University

Bachelor of Computer Application

Semester 3 · TU Board 2026

Course Title: Object Oriented Programming in Java (CACS204)

Full Marks: 60Pass Marks: 24Time: 3 hours

Group B

Attempt any SIX question.(6 × 5 = 30)

  1. 11.

    Differentiate between JDK, JRE, and JVM. Explain how Java source code is compiled into bytecode and executed by the JVM with a suitable example.

    5
  2. 12.

    What is a constructor in Java? Explain default and parameterized constructors with a suitable Java program.

    5
  3. 13.

    What is method overriding? Write a Java program using a parent class and child class to demonstrate method overriding and runtime polymorphism.

    5
  4. 14.

    Explain exception handling in Java. Write a program that uses try, catch, finally, and throw to handle an invalid division operation.

    5
  5. 15.

    What is multithreading? Write a Java program to create two threads using the Runnable interface, where one thread prints numbers from 1 to 5 and another prints letters from A to E.

    5
  6. 16.

    Explain the Java Collection Framework. Write a program using ArrayList to store student names and HashMap to store student names with their corresponding marks.

    5
  7. 17.

    What is a package in Java? Explain the advantages of packages and write a program to create a user-defined package named 'college' containing a class 'Student', then import and use it in another class.

    5

Group A

Attempt ALL questions.(10 × 1 = 10)

  1. 1.

    What is meant by platform independence in Java?

    1
  2. 2.

    Write any two differences between a class and an object.

    1
  3. 3.

    What is the default value of an instance variable of type int in Java?

    1
  4. 4.

    Which keyword is used to inherit a class in Java?

    1
  5. 5.

    What is the purpose of the 'this' keyword in Java?

    1
  6. 6.

    Name any two checked exceptions in Java.

    1
  7. 7.

    Which method is used to start the execution of a Java thread?

    1
  8. 8.

    Which interface is implemented to make an object serializable in Java?

    1
  9. 9.

    Name the Java collection class that stores only unique elements.

    1
  10. 10.

    Write the general syntax of a lambda expression in Java.

    1

Group B

Attempt any SIX questions.(6 × 5 = 30)

  1. 11.

    Differentiate between JDK, JRE, and JVM. Explain how Java source code is compiled into bytecode and executed by the JVM with a suitable example.

    5
  2. 12.

    What is a constructor in Java? Explain default and parameterized constructors with a suitable Java program.

    5
  3. 13.

    What is method overriding? Write a Java program using a parent class and child class to demonstrate method overriding and runtime polymorphism.

    5
  4. 14.

    Explain exception handling in Java. Write a program that uses try, catch, finally, and throw to handle an invalid division operation.

    5
  5. 15.

    What is multithreading? Write a Java program to create two threads using the Runnable interface, where one thread prints numbers from 1 to 5 and another prints letters from A to E.

    5
  6. 16.

    Explain the Java Collection Framework. Write a program using ArrayList to store student names and HashMap to store student names with their corresponding marks.

    5
  7. 17.

    What is a package in Java? Explain the advantages of packages and write a program to create a user-defined package named 'college' containing a class 'Student', then import and use it in another class.

    5

Group C

Attempt any TWO questions.(2 × 10 = 20)

  1. 18.

    Define inheritance and explain its different types in Java with suitable examples. Discuss how Java supports multiple inheritance through interfaces. Write a Java program demonstrating hierarchical inheritance and the use of the 'super' keyword.

    10
  2. 19.

    Explain file handling in Java. Write a program to: a. Create a file named 'employees.txt' and write five employee names using character streams. b. Read the contents of the file and display them on the console. c. Explain the difference between byte streams and character streams.

    10
  3. 20.

    Design a Java application for a simple Online Shopping System using object-oriented principles. Your program should: a. Create a class 'Product' with attributes productId, name, price, and quantity. Include a constructor, getters/setters, and a display() method. b. Create a subclass 'ElectronicProduct' that extends 'Product' and adds a warrantyPeriod attribute. Override the display() method. c. Use an ArrayList to store at least 3 Product/ElectronicProduct objects and display all product details. d. Create and handle a user-defined exception 'InvalidPriceException' if a product is created with a negative price.

    10

— The End —