Advanced Java Programming (BSc CSIT, CSC409): the questions likely to come
93 analyzed questions from 8 past papers (2074-2082), grouped by syllabus unit — each with its probability, how often it's been asked, and where to study the answer.
Write a JavaFX application that creates a ChoiceBox with a list of colors. Display a label that changes its text based on the selected color from the ChoiceBox. Write down steps for writing CORBA programs with a suitable example.
JavaFX ChoiceBox Application
ChoiceBox is a JavaFX control that shows a drop-down list of items for single selection. We listen to its selection model with a ChangeListener (or a binding) and update a Label whenever the chosen color changes.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ColorChoiceApp extends Application {
@Override
public void start(Stage stage) {
ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll("Red", "Green", "Blue", "Yellow");
choiceBox.setValue("Red");
Label label = new Label("Selected color: Red");
// Update label whenever the selected color changes
choiceBox.getSelectionModel().selectedItemProperty().addListener(
(obs, oldVal, newVal) -> label.setText("Selected color: " + newVal));
VBox root = new VBox(10, choiceBox, label);
Scene scene = new Scene(root, 300, 150);
stage.setTitle("ChoiceBox Demo");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
When the user picks a color from the ChoiceBox, the listener fires and the Label text changes to reflect the selection.
Steps for Writing CORBA Programs
CORBA (Common Object Request Broker Architecture) is a standard from the OMG that lets objects written in different languages on different machines communicate through an ORB (Object Request Broker) using IDL (Interface Definition Language).
Steps:
- Define the interface in IDL — declare the remote operations in a language-neutral
.idlfile. - Compile the IDL with the IDL-to-Java compiler (
idlj) to generate the stub (client side), skeleton (server side), and helper/holder classes. - Implement the servant — write a Java class that extends the generated skeleton (
...POA) and implements the interface operations. - Write the server — create the ORB, get the POA, instantiate the servant, register/bind its object reference with the Naming Service, and wait for requests.
- Write the client — initialize the ORB, look up the object reference from the Naming Service, narrow it to the interface type, and invoke remote methods.
- Run — start
orbd(the naming/activation daemon), then the server, then the client.
Example IDL — Hello.idl
module HelloApp {
interface Hello {
string sayHello();
};
};
Servant
import HelloApp.*;
class HelloImpl extends HelloPOA {
public String sayHello() { return "Hello from CORBA server"; }
}
Server (skeleton)
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
HelloImpl servant = new HelloImpl();
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(servant);
Hello href = HelloHelper.narrow(ref);
// bind 'href' in the naming service, then orb.run();
Client (skeleton)
ORB orb = ORB.init(args, null);
// resolve "Hello" from naming service into 'helloRef'
Hello helloRef = HelloHelper.narrow(ncRef.resolve_str("Hello"));
System.out.println(helloRef.sayHello());
Thus CORBA achieves language- and platform-independent distributed object communication via IDL and the ORB.
Event Handling and GUI Programming
Write a JavaFX application that creates a ChoiceBox with a list of colors. Display a label that changes its text based on the selected color from the ChoiceBox. Write down steps for writing CORBA programs with a suitable example.
Explain GUI programming using Swing. Discuss the component hierarchy and write a program to build a registration form with validation using Swing components.
Describe the Java event handling mechanism with appropriate examples. Write a Swing GUI program that implements a simple calculator with buttons for basic arithmetic operations.
Explain the delegation event model. Write a Swing program that demonstrates handling of action events and item events on multiple components.
Discuss the architecture of Swing. Write a GUI application using Swing that accepts user details through text fields and displays them in a dialog box.
Explain event-driven programming in Java. Discuss the event delegation model and write a program demonstrating handling of mouse events.
Write a program to insert an icon in the frame and when the user presses the up arrow, it will move upward.
Write a program to design a layout of a simple calculator. (Arithmetic operation not required.)
Write a program to demonstrate the concept of internal frame.
Do we still need Java Applet? Justify. Give the hierarchy of Swing class.
Compare AWT with Swing. Explain the MVC architecture used in Swing components with a suitable diagram.
Explain the JList and JComboBox components.
What is the delegation event model? List its components.
What is Swing? Explain the benefits of using Swing components over AWT. Write a GUI program using Swing components to find the sum and difference of two numbers.
Explain any three Swing layout managers.
Differentiate between AWT and Swing components.
What is an event source and an event listener?
Explain the JScrollPane and JTabbedPane components.
Discuss any three event listener interfaces in Java.
What is the difference between a container and a component in Swing?
Explain the CardLayout manager with an example.
What are the benefits of using Swing components?
What is a layout manager? Explain GridLayout.
What is the use of the JTable component? Explain.
Explain adapter classes in Java event handling.
Discuss any three event classes in Java with examples.
What is a layout manager? Explain BorderLayout and FlowLayout.
Explain the delegation event model in Java.
Sit a probable paper
A full mock exam built from the most likely questions, mirroring the real paper's structure. Every slot is a real past question.
Most Probable Paper
Mirrors the real structure · 60 marks · based on 8 past papers
- 1.[10 marks]
Write a JavaFX application that creates a ChoiceBox with a list of colors. Display a label that changes its text based on the selected color from the ChoiceBox. Write down steps for writing CORBA programs with a suitable example.
Asked once (2082); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 2.[10 marks]
Explain GUI programming using Swing. Discuss the component hierarchy and write a program to build a registration form with validation using Swing components.
Asked once (2081); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 3.[10 marks]
Describe the Java event handling mechanism with appropriate examples. Write a Swing GUI program that implements a simple calculator with buttons for basic arithmetic operations.
Asked once (2080); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 1.[5 marks]
What is the difference between TCP and UDP socket programming?
This question has recurred in 3 of 8 years; so far only in internal assessments, not the board; and its topic (Network Programming) appears in 100% of years.
- 2.[5 marks]
Write short notes on exception handling in JDBC.
This question has recurred in 2 of 8 years; so far only in internal assessments, not the board; and its topic (Multithreading Programming and Database Connectivity) appears in 100% of years.
- 3.[5 marks]
Write a program to insert an icon in the frame and when the user presses the up arrow, it will move upward.
Asked once (2082); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 4.[5 marks]
Write a program to design a layout of a simple calculator. (Arithmetic operation not required.)
Asked once (2082); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 5.[5 marks]
Write a program to demonstrate the concept of internal frame.
Asked once (2082); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 6.[5 marks]
Do we still need Java Applet? Justify. Give the hierarchy of Swing class.
Asked once (2082); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 7.[5 marks]
Explain the JList and JComboBox components.
Asked once (2081); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 8.[5 marks]
What is the delegation event model? List its components.
Asked once (2081); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
- 9.[5 marks]
Explain any three Swing layout managers.
Asked once (2080); so far only in internal assessments, not the board; and its topic (Event Handling and GUI Programming) appears in 100% of years.
Behind the numbers
The raw evidence the predictions are computed from: marks per unit per year, syllabus weights, trends, and coverage.
Show the heatmap, topic table and coverage analysis
The receipt: marks per unit, per year
Each row is a syllabus unit, each column an exam year, each cell the marks that unit earned that year. Click any cell to see the actual questions behind it.
| # | Syllabus unit | Probability | Appeared | Avg marks | Syllabus weight | Exam vs syllabus | Trend | Questions |
|---|---|---|---|---|---|---|---|---|
| 1 | U2Event Handling and GUI Programming | Very likely100% | 22.5 | 16%7 lecture hrs | Over-examinedexam 30% · syllabus 16% | Steady | none repeat28 total | |
| 2 | U4Network Programming | Very likely100% | 15.6 | 11%5 lecture hrs | Over-examinedexam 21% · syllabus 11% | Steady | 1 recurring18 total | |
| 3 | U3Multithreading Programming and Database Connectivity | Very likely100% | 13.8 | 18%8 lecture hrs | Balancedexam 18% · syllabus 18% | Steady | 1 recurring16 total | |
| 4 | U5Java Servlets | Very likely100% | 11.2 | 13%6 lecture hrs | Balancedexam 15% · syllabus 13% | Fading | none repeat15 total | |
| 5 | U6Java Server Pages (JSP) | Very likely100% | 9.4 | 13%6 lecture hrs | Balancedexam 12% · syllabus 13% | Steady | none repeat12 total | |
| 6 | U1Programming in Java | Occasional25% | 10 | 11%5 lecture hrs | Under-examinedexam 3% · syllabus 11% | Rising | none repeat4 total | |
| 7 | U7Enterprise JavaBeans (EJB) and Hibernate | Occasional0% | 0 | 18%8 lecture hrs | Under-examinedexam 0% · syllabus 18% | Steady | None |
Study smart, not hard
Drag the slider: studying the top 4 units in priority order covers ~84% of all observed marks.
- ~80% line
Lecture time vs exam marks
Where the exam pays more than the curriculum spends: ● lectures vs ● exam marks, as a share of the whole course. A long teal-leading bar = high-yield unit.