BE Computer Engineering (Pokhara University) Advanced Programming with Java (PU, CMP 228) Question Paper 2079
This is the official BE Computer Engineering (Pokhara University) Advanced Programming with Java (PU, CMP 228) question paper for 2079, as set in the regular annual examination. It carries 100 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this Advanced Programming with Java (PU, CMP 228) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BE Computer Engineering (Pokhara University) Advanced Programming with Java (PU, CMP 228) exam or solving previous years' question papers, this 2079 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt all / any as specified.
(a) Explain the four fundamental principles of Object-Oriented Programming (encapsulation, inheritance, polymorphism and abstraction) and discuss how each is supported by features of the Java language. (7)
(b) Distinguish between method overloading and method overriding in Java with suitable code examples. Explain the role of the super and this keywords and the use of the final modifier when applied to a method and a class. (8)
(a) Describe the life cycle of a thread in Java with a neat labelled state-transition diagram, explaining the transitions between the new, runnable, running, blocked/waiting and dead states. (6)
(b) What is meant by thread synchronization? Write a complete multithreaded Java program that implements the classic producer–consumer problem using wait() and notify() on a shared bounded buffer, and explain how your solution avoids race conditions. (9)
(a) List and explain the four types of JDBC drivers, stating one advantage and one disadvantage of each. (6)
(b) Write a complete Java program that connects to a MySQL database, retrieves all records from an Employee(empId, name, salary) table using a PreparedStatement, and prints them. Clearly identify the standard steps of JDBC connectivity used in your program and explain the difference between Statement and PreparedStatement. (8)
(a) Explain the Java event delegation model. Describe the roles of the event source, event object and event listener with reference to handling a button click in Swing. (5)
(b) Design and write a Swing-based GUI application for a simple login form containing two text fields (username and password) and a Login button. When the button is clicked, the program should display a message dialog indicating whether the entered credentials match a hard-coded valid pair. Use an appropriate layout manager. (7)
Section B: Short Answer Questions
Attempt all / any as specified.
Differentiate between checked and unchecked exceptions in Java. Explain the use of the try, catch, finally, throw and throws constructs, and write a short program that defines and throws a user-defined (custom) exception.
Describe the Java Collections Framework hierarchy. Compare ArrayList vs LinkedList and HashMap vs TreeMap in terms of internal structure and performance. Write a short code snippet that uses an Iterator to traverse a generic List<String>.
Explain the difference between TCP and UDP communication in Java. Write a simple TCP client–server program (server and client code) in which the server echoes back any message sent by the client, using the ServerSocket and Socket classes.
Explain the life cycle of a servlet, describing the purpose of the init(), service() and destroy() methods. How does a servlet differ from a JSP page, and at what point is a JSP converted into a servlet?
Differentiate between the String, StringBuffer and StringBuilder classes in Java with respect to mutability and thread safety. Explain why String is said to be immutable and what is meant by the string constant pool.
Compare the two ways of creating a thread in Java: extending the Thread class versus implementing the Runnable interface. State which approach is generally preferred and justify your answer with an example signature.
Explain the role of the ResultSet interface in JDBC. Differentiate between a forward-only and a scrollable result set, and write code to update a column value through an updatable ResultSet.
What is the difference between an abstract class and an interface in Java? With the introduction of default and static methods, explain how interfaces have evolved since Java 8.