Java External Oral
Java External Oral
Operator Meaning
< Less than
> Greater than
<= Less than or
equal to
>= Greater than or
equal to
== Equal to
!= Not equal to
2. Enlist access specifiers in Java.
The access specifiers in java specify accessibility (scope) of a data
member, method, constructor or class. There are 5 types of java access
specifier:
• public
• private
• default (Friendly)
• protected
• private protected
3. Explain constructor with suitable example.
Constructors are used to assign initial value to instance variable of the
class. It has the same name as class name in which it resides and it is
syntactically similar to any method. Constructors do not have return
value, not even ‘void’ because they return the instance if class.
Constructor called by new operator.
Example:
class Rect
{
int length, breadth;
Rect() //constructor
{
length=4; breadth=5;
}
public static void main(String args[])
{
Rect r = new Rect();
System.out.println(“Area : ” +(r.length*r.breadth));
}
}
Output : Area : 20
4. List the types of inheritance which is supported by java.
• java.applet
Use of finalize( ): Sometimes an object will need to perform some action when
it is destroyed. Eg. If an object holding some non java resources such as file
handle or window character font, then before the object is garbage collected
these resources should be freed. To handle such situations java provide a
mechanism called finalization. In finalization, specific actions that are to be
done when an object is garbage collected can be defined. To add finalizer to a
class define the finalize() method. The java run-time calls this method
whenever it is about to recycle an object.
Syntax: protected void finalize() {
}
21. Name the wrapper class methods for the following:
(i) To convert string objects to primitive int.
(ii) To convert primitive int to string objects.
(i) To convert string objects to primitive int:
String str=”5”;
int value = Integer.parseInt(str);
(ii) To convert primitive int to string objects:
int value=5;
String str=Integer.toString(value);
22. List the types of inheritances in Java. (Note: Any four types shall be
considered)
Types of inheritances in Java:
i. Single level inheritance
ii. Multilevel inheritance
iii. Hierarchical inheritance
iv. Multiple inheritance
v. Hybrid inheritance
23. Write the syntax of try-catch-finally blocks
try{
//Statements to be monitored for any exception
}
catch(ThrowableInstance1 obj) {
//Statements to execute if this type of exception occurs
} catch(ThrowableInstance2 obj2) {
//Statements
}finally{
//Statements which should be executed even if any exception happens
}
24. What is an event? How is it handled in Java?
An event is an action or occurrence detected by the program, typically
originating from user input like mouse clicks, keyboard presses, or other
system events. In Java, events are handled through event listeners, which
listen for specific types of events and execute code in response. Java's event
handling mechanism is based on the Observer design pattern, where event
sources generate events, and event listeners handle those events.
25. Define AWT.
AWT (Abstract Window Toolkit) is a set of application programming interfaces
(APIs) provided by Java to create graphical user interfaces (GUIs). It includes
components like buttons, text fields, and windows. AWT uses the underlying
operating system's GUI components, making it less flexible compared to Swing.
26. List the different AWT controls.
Some of the main AWT controls include:
• Button
• Label
• TextField
• TextArea
• Checkbox
• RadioButton
• List
• Choice
• Scrollbar
• Canvas
27. What is a layout manager in Java?
A layout manager is responsible for arranging the components within a
container (like a window or a frame) in Java. It automatically adjusts the size
and position of the components. Some commonly used layout managers
include FlowLayout, BorderLayout, GridLayout, and CardLayout
28. Enumerate key features of Swing.
Swing is a part of Java's Standard Library that provides a more flexible and
powerful way to build graphical user interfaces. Key features include:
• Platform-independent, written entirely in Java.
• Lightweight components (do not rely on the operating system's GUI
components).
• Rich set of controls like JButton, JLabel, JTable, etc.
• Built-in support for pluggable look-and-feel (customizable GUI themes).
• Event-handling using listeners, with support for complex event handling.
• Support for 2D graphics and user interface effects.
29. What is JDBC?
JDBC (Java Database Connectivity) is an API in Java that allows Java
applications to connect to relational databases, execute SQL queries, and
process the results. It provides a standard interface for database interaction.
30. List the four types of JDBC drivers.
The four types of JDBC drivers are:
1. JDBC-ODBC Bridge Driver (Type 1)
2. Native-API Driver (Type 2)
3. Network Protocol Driver (Type 3)
4. Thin Driver (Type 4)
30. Define ODBC.
ODBC (Open Database Connectivity) is an open standard API for accessing
database management systems (DBMS). ODBC allows applications to
communicate with different DBMSs without needing to know the specific
database details.
31. What is the importance of a proxy server?
A proxy server acts as an intermediary between a client and a server. It is used
to:
• Improve security by hiding the client's real IP address.
• Control and monitor internet usage.
• Cache data for faster access.
• Filter content and restrict access to certain websites or services.
32. Define "client" and "server" in networking
• A client is a device or program that requests services or resources from
a server. It is typically a computer or software that connects to a server.
• A server is a device or program that provides services or resources to
clients. It listens for requests from clients and responds accordingly