What is the default value of a local variable in Java?
A. 0
B. null
C. undefined
D. None of the above
Answer: C
What is the purpose of inheritance in Java?
A. To
reuse existing code
B. To avoid writing new code
C. To create new code
D. To make code easier
to read
Answer: A
What is the difference between an object and a class in Java?
A. An
object is a blueprint, a class is a prototype
B. A class is a blueprint, an object is a prototype
C.
An object is an instance, a class is a blueprint
D. A class is an instance, an object is a blueprint
Answer: B
What is the purpose of packaging in Java?
A. To group related classes and interface
s together
B. To ensure that classes cannot access each other
C. To create a separate namespace for c
lasses
D. To allow classes to be used by other programs
Answer: A
What is the purpose
of exceptions in Java?
A. To indicate that an error has occurred
B. To indicate that a program is com
plete
C. To indicate that a program has been compiled successfully
D. To indicate that a program is r
unning
Answer: A
What is the difference between a String and a StringBuilder in Java?
A. A String is immutable, a StringBuilder is mutable
B. A StringBuilder is immutable, a String is mutable
C. A String is a class, a StringBuilder is an interface
D. A StringBuilder is a class, a String is an in
terface
Answer: A
What is the purpose of threads in Java?
A. To improve the performanc
e of a program by running multiple tasks simultaneously
B. To organize code into a hierarchy of tasks
C. To allow a program to run in the background
D. To simplify the coding of multi-threaded programs
A
nswer: A
What is the purpose of I/O and Streams in Java?
A. To read and write data from and t
o external sources
B. To manipulate data in memory
C. To store data in a database
D. To trans
fer data between programs
Answer: A
What is the purpose of the Core Java Packages?
A.
To provide a set of standard tools for developing Java programs
B. To simplify the coding of complex programs
C. To provide a set of standard algorithms for solving common problems
D. To provide a set of standa
rd data structures for storing data
Answer: A
What is the purpose of the Collection framework
in Java?
A. To provide a set of classes and interfaces for holding groups of data
B. To provide a set
of algorithms for searching and sorting data
C. To provide a set of classes and interfaces for managing data
bases
D. To provide a set of classes and interfaces for manipulating text data
Answer: A
What is the default layout manager used by the AWT framework in Java?
A. BorderLayout
B. FlowLayou
t
C. GridLayout
D. CardLayout
Answer: B
What is the purpose of applets in Jav
a?
A. To create small, dynamic, graphical applications that can run in a web browser
B. To create smal
l, static, graphical applications that can run in a web browser
C. To create large, dynamic, graphical applic
ations that can run on a desktop
D. To create large, static, graphical applications that can run on a desktop
Answer: A
What is JDBC in Java?
A. Java Database Connectivity, a framework for connec
ting to and manipulating databases
B. Java Data Backup and Compression, a framework for backing up and compre
ssing data
C. Java Data Backup and Conversion, a framework for backing up and converting data
D. Java
Data Backup and Compression, a framework for backing up and compressing databases
Answer: A
What is the difference between a Statement and a PreparedStatement in JDBC?
A. A Statement is used for executi
ng static SQL statements, a PreparedStatement is used for executing dynamic SQL statements
B. A PreparedState
ment is used for executing static SQL statements, a Statement is used for executing dynamic SQL statements
C.
A Statement is used for executing SQL statements, a PreparedStatement is used for executing stored procedures
D. A PreparedStatement is used for executing SQL statements, a Statement is used for executing stored proceduresAnswer: A
What is the difference between a ResultSet and a RowSet in JDBC?
A. A ResultSe
t is a live database cursor, a RowSet is a disconnected result set
B. A RowSet is a live database cursor, a R
esultSet is a disconnected result set
C. A ResultSet is used for reading data from a database, a RowSet is us
ed for updating data in a database
D. A RowSet is used for reading data from a database, a ResultSet is used
for updating data in a database
Answer: A
What is the purpose of the ResultSetMetaData interf
ace in JDBC?
A. To retrieve metadata about the columns in a ResultSet
B. To retrieve metadata about th
e tables in a database
C. To retrieve metadata about the data stored in a database
D. To retrieve met
adata about the structure of a database
Answer: A
What is the difference between inheritance
and composition in Java?
A. Inheritance allows for code reuse through inheritance of properties and methods fr
om a parent class, composition allows for code reuse through composition of objects from other classes
B. Com
position allows for code reuse through inheritance of properties and methods from a parent class, inheritance allows
for code reuse through composition of objects from other classes
C. Inheritance and composition both allow fo
r code reuse through inheritance of properties and methods from a parent class
D. Inheritance and composition
both allow for code reuse through composition of objects from other classes
Answer: A
What i
s the purpose of exceptions in Java?
A. To handle errors and unexpected conditions during program execution
B. To validate user input and provide feedback
C. To improve the performance of a program
D. To
provide debugging information
Answer: A
What is the difference between a Thread and a Runnab
le in Java?
A. A Thread is a concrete implementation of the Thread class, a Runnable is an interface that can
be implemented to create a Thread
B. A Runnable is a concrete implementation of the Thread class, a Thread is
an interface that can be implemented to create a Runnable
C. A Thread is an interface that can be implemente
d to create a Runnable, a Runnable is a concrete implementation of the Thread class
D. A Runnable is an inter
face that can be implemented to create a Thread, a Thread is a concrete implementation of the Thread class
Ans
wer: A
What is the purpose of streams in Java?
A. To allow for efficient reading and writing
of data to and from input and output sources
B. To allow for efficient processing of data in memory
C
. To allow for efficient storage of data in a database
D. To allow for efficient compression and decompressio
n of data
Answer: A
What is the purpose of the core packages in Java?
A. To provide ba
sic functionality for building Java applications, such as handling strings, reading and writing data, and managing co
llections of data
B. To provide advanced functionality for building Java applications, such as graphical user
interfaces, database connectivity, and networking
C. To provide low-level functionality for building Java ap
plications, such as memory management and system-level access
D. To provide performance optimizations for bui
lding Java applications