APRIL 2025
2MARKS:
[Link] is Object-Oriented Programming?
Object-oriented programming (OOP) organizes a program around its data (objects) and the well-
defined interfaces used to access that [Link] uses main concepts like Class, Object, Inheritance,
Polymorphism, Encapsulation, and Abstraction.
[Link] is the purpose of the main method in a Java program?
The main() method is the starting point of Java program execution. When a Java program runs, it
begins from the main() method, creates objects, and calls other methods inside the class.
Although Java can compile a class without a main() method, it cannot run that class because the
main() method is essential for execution.
[Link] the primary difference between String and String Buffer classes in Java.
The primary difference between string and string buffer classes in Java is its [Link]
is immutable, so it cannot be changed and any modification creates a new object. StringBuffer is
mutable, it can be changed directly, making it faster for repeated modifications.
[Link] a user-defined class in Java.
A user-defined class is a class created by the programmer (not built-in) to represent their own
data and functions.
[Link] the different types of inheritance in Java.
Java supports 3 types:Single inheritance,Multilevel inheritance,Hierarchical inheritance
[Link] is the purpose of the finally block in exception handling?
The finally block contains code that always runs, whether an exception occurs or not.
Used for cleanup tasks like closing files, databases, etc.
7. Identify the difference between throw and throws in Java.
throw throws
Used inside a method to manually throw an Used in method signature to declare
exception exceptions
Only throws one exception at a time Can declare multiple exceptions
Example: throw new Exception(); Example: void show() throws IOException
8. What is the purpose of the AWT class hierarchy in Java?
The AWT (Abstract Window Toolkit) class hierarchy provides classes for building GUI
applications like windows, buttons, text fields, menus, etc., using system-dependent components.
The hierarchy is designed in such a way that all GUI elements are organized under parent classes
like Component, Container, and Window. This structure helps in reusing features, managing
events, handling user interactions, and displaying platform-dependent GUI components
9. Define a top-level container in Swing.
A top-level container is the main window that holds all Swing components.
They do not require to be added inside another component.
Swing provides three top-level container classes: JFrame, JDialog, and JApplet.
[Link] is the function of the JLabel component in Swing?
JLabel is a class of java Swing. JLabel is used to display a short string or an image icon. JLabel
can display text, image or both.
11. What is an adapter class in Java?
An adapter class provides empty implementations for all methods of a listener interface.
Used when you want to override only a few methods, not all.
Example: MouseAdapter, KeyAdapter.
12. What is the role of the Comparator interface?
The Comparator interface is used to define custom sorting for objects. It provides the compare()
method to compare two objects and the equals() method to check if two comparators are equal,
allowing flexible sorting without changing the original class.