CSC419 · TU past paper
Advanced Java Programming 2076 question paper
The complete TU 2076 exam paper for Advanced Java Programming (CSC419), all 13 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- Q1.10 marksHandling ExceptionsHideAnswer
What is exception handling? Discuss the use of each keyword (try, catch, throw, throws and finally) with suitable Java program.[10]
- Q2.10 marksHandling Action Events, Key Events, Focus HideAnswer
Write a Java program to find the sum of two numbers using swing components. Use text fields for input and output. Your program displays output if you press any key in keyboard. Use key adapter to handle events.[10]
- Q3.10 marksWeb Container, Introduction to Servlets, LHideAnswer
Define servlet. Discuss life cycle of servlet. Differentiate servlet with JSP. Write a simple JSP file to display 'IOST' 20 times.[10]
- Q4.5 marksClass and ObjectHideAnswer
Define class. How do you create a class in Java? Differentiate class with interface. [5]
Class in Java: Definition, Creation, and Difference with Interface
Definition of Class
A class in Java is a blueprint or template from which objects are created. It defines the properties (fields/attributes) and behaviors (methods) that the objects of that class will have. A class encapsulates data and the methods that operate on that data into a single unit.
Syntax:
class ClassName { // fields (attributes) // methods (behaviors) }
Creating a Class in Java
A class is created using the
classkeyword followed by the class name. It can contain:- Fields (variables to store data)
- Methods (functions to define behavior)
- Constructors (to initialize objects)
Example:
class Student { // Fields int rollNo; String name; // Constructor Student(int r, String n) { rollNo = r; name = n; } // Method void display() { System.out.println("Roll No: " + rollNo + ", Name: " + name); } } // Using the class public class Main { public static void main(String[] args) { Student s = new Student(1, "Ram"); // object creation s.display(); } }
Difference Between Class and Interface
Basis Class Interface Keyword Declared using classkeywordDeclared using interfacekeywordMethods Can have both abstract and concrete (implemented) methods All methods are abstract by default (empty body) Fields Can have instance variables of any type All fields are public,static, andfinalby defaultInstantiation Objects can be created directly from a class Cannot be instantiated directly Inheritance Supports single inheritance ( extends)Supports multiple inheritance (a class can implementmultiple interfaces)Access Modifiers Methods can have any access modifier Methods are publicandabstractby defaultConstructor Can have constructors Cannot have constructors Purpose Used to define object structure and behavior Used to achieve abstraction and loose coupling Implementation A class uses extendsto inherit another classA class uses implementsto use an interface
Key Note
An interface is a blueprint of a class used to achieve:
- Abstraction
- Multiple inheritance (not supported directly with classes in Java)
- Loose coupling
A class that implements an interface must implement all the methods declared in that interface.
- Q5.5 marksWorking with FilesHideAnswer
Write a simple Java program that reads a file named 'Test.txt' and displays its contents. [5]
- Q6.5 marksLayout ManagementHideAnswer
Why do we need layout management? What is GridBag layout? [5]
- Q7.5 marksIntroduction to Java Web FrameworksHideAnswer
Discuss MVC design pattern with example. [5]
- Q8.5 marksDDL and DML Operations using Java, PrepareHideAnswer
What are the benefits of using JDBC? What is prepared statement? [5]
- Q9.5 marksSocket programming using TCP, Socket progrHideAnswer
Write Java programs using TCP sockets that communicate with each other in a computer network. [5]
- Q10.5 marksCompiling and Running Java ProgramsHideAnswer
Define Java Bean. How is it different from other Java programs? What is design pattern? [5]
- Q11.5 marksWeb Container, Introduction to Servlets, LHideAnswer
How do you handle HTTP request (GET) using servlet? [5]
- Q12.5 marksIntroduction of RMI, Architecture of RMI, HideAnswer
What are different layers of RMI architecture? Explain. [5]
- Q13.5 marksWeb Container, Introduction to Servlets, LHideAnswer
Write short notes on: a. Servlet API b. RMI vs CORBA [2.5+2.5]