You are on page 1of 17

MCQ’s Question Bank of Java Programming

B. TECH 6th Semester


1. Which programming paradigm is primarily used in Java?

A) Procedural

B) Functional

C) Object-oriented

D) Logical

2. What is Java primarily known for in the context of the internet?


A) Speed
B) Security
C) Portability
D) Scalability
3. Which keyword is used to define a constant in Java?
A) const
B) final
C) static
D) constant
4. What is the main purpose of a variable in Java?
A) To store data temporarily
B) To perform mathematical operations
C) To define class methods
D) To handle exceptions
5. Which of the following is not a primitive data type in Java?
A) int
B) float
C) string
D) boolean
6. What does the '=='' operator check for in Java?
A) Value equality
B) Reference equality
C) Type equality
D) Object equality
7. Which loop is guaranteed to execute at least once in Java?
A) for loop
B) while loop
C) do-while loop
D) switch loop
8. What does the 'break' statement do in Java?
A) Exits the loop or switch statement
B) Skips the current iteration of the loop
C) Continues to the next iteration of the loop
D) Terminates the program
9. Which keyword is used to skip the current iteration and continue to the next iteration of a loop
in Java?
A) skip
B) pass
C) continue
D) next
10. Which of the following statements is used to transfer control to another part of the program in
Java?
A) break
B) continue
C) return
D) goto
11. In Java, the switch statement is primarily used for:
A) Decision making
B) Looping
C) Exception handling
D) Object creation
12. Which keyword is used to define a case inside a switch statement in Java?
A) case
B) if
C) then
D) switch
13. Which of the following is NOT a fundamental principle of object-oriented programming?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Procedural Decomposition
14. In which year was Java first released?
a) 1990
b) 1995
c) 2000
d) 2005
15. Java is known for its platform independence thanks to:
a) Compiled code
b) Bytecode
c) String
d) Objects
16. Which of the following keywords is used to declare a constant value in Java?
a) int
b) const
c) final
d) var
17. What data type in Java can store whole numbers?
a) float
b) char
c) int
d) String
18. The == operator in Java is used for:
a) Logical AND
b) Logical OR
c) Assignment
d) Equality Comparison
19. The if statement allows for:
a) Unconditional execution of code
b) Conditional execution of code
c) Looping through a set of instructions
d) Defining functions
20. The switch statement is used for:
a) Looping based on a counter
b) Conditional branching based on multiple values
c) Declaring variables
d) Calling functions
21. The while loop continues to execute a block of code as long as a certain condition is:
a) Always true
b) Sometimes true
c) Defined beforehand
d) Limited to a specific number of iterations
22. The break statement is used to:
a) Continue looping
b) Exit a loop prematurely
c) Jump to the next iteration
d) Define a loop condition
23. What is the primary purpose of using classes in object-oriented programming?
A) To store data
B) To organize code
C) To facilitate inheritance
D) All of the above Answer:
24. Which of the following is NOT a component of a class definition?
A) Variables
B) Methods
C) Constructors
D) Objects
25. What is a constructor in Java?
A) A method used to create objects
B) A method used to initialize variables
C) A method used to destroy object
D) A method used to access class members
26. In Java, what keyword is used to inherit a class?
A) extend
B) inherit
C) implements
D) extends
27. What is the purpose of using arrays in Java?
A) To store a collection of objects
B) To store a collection of primitive data types
C) To organize code
D) To facilitate inheritance
28. Which of the following correctly initializes a one-dimensional array of integers in Java?
A) int[] array = new int[];
B) int[] array = new int[10];
C) int array[10];
D) int array[];
29. What is the length of a one-dimensional array in Java?
A) The number of elements it contains
B) The number of bytes it occupies in memory
C) The index of the last element
D) The number of dimensions it has
30. How do you access elements in a one-dimensional array in Java?
A) Using the index of the element
B) Using the length of the array
C) Using a loop
D) All of the above
31. What is the correct way to declare a two-dimensional array in Java?
A) int[][] array = new int[][];
B) int[][] array = new int[5][];
C) int[][] array = new int[][]{};
D) int[][] array = new int[5][5];
32. Which of the following methods is used to obtain the length of a string in Java?
A) length()
B) size()
C) count()
D) length
33. What is the primary difference between String and StringBuffer classes in Java?
A) String is mutable, StringBuffer is immutable
B) String is immutable, StringBuffer is mutable
C) String allows for string concatenation, StringBuffer does not
D) StringBuffer allows for string comparison, String does not
34. Which of the following is NOT a wrapper class in Java?
A) Integer
B) Double
C) Float
D) Char
35. What is the purpose of wrapper classes in Java?
A) To convert primitive data types into objects
B) To provide utility methods for primitive data types
C) To improve code readability
D) All of the above
36. Which of the following is a valid constructor declaration in Java?
A) public void MyClass()
B) public MyClass()
C) public MyClass(int x)
D) Both B and C
37. In Java, what does the 'super' keyword refer to?
A) Refers to the current instance of the class
B) Refers to the superclass of the class
C) Refers to the subclass of the class
D) Refers to the interface implemented by the class
38. Which of the following is a valid way to create an object in Java?
A) MyClass x = new MyClass();
B) new MyClass x = MyClass();
C) MyClass x = create MyClass();
D) MyClass x = MyClass.create();
39. What is the syntax for accessing a method of an object in Java?
A) objectName.methodName();
B) methodName.objectName();
C) objectName->methodName();
D) methodName->objectName();
40. Which keyword is used to prevent a method from being overridden in Java?
A) prevent
B) final
C) override
D) static
41. What is the purpose of the 'this' keyword in Java?
A) Refers to the current instance of the class
B) Refers to the superclass of the class
C) Refers to the subclass of the class
D) Refers to the interface implemented by the class
42. Which of the following is true about constructors in Java?
A) They have a return type
B) They are used to initialize objects
C) They can be inherited
D) They can be overloaded
43. Which of the following is NOT a valid data type in Java?
A) int
B) string
C) double
D) boolean
44. What is the purpose of the 'implements' keyword in Java?
A) To implement multiple inheritance
B) To extend a class
C) To specify that a class implements an interface
D) To specify that a class extends another class
45. Which of the following statements about inheritance in Java is true?
A) A subclass inherits all the methods and variables of its superclass
B) A superclass inherits all the methods and variables of its subclass
C) A subclass can only inherit methods, not variables, from its superclass
D) Inheritance is not supported in Java
46. What is the purpose of classes in Java?
A) To store data
B) To organize code logically
C) To perform mathematical operations
D) To create graphical user interfaces
47. Which keyword is used to define a class in Java?
A) class
B) define
C) struct
D) interface
48. Which section of a class contains variables and methods?
A) Constructor
B) Data members
C) Member functions
D) Main method
49. What is the purpose of a constructor in Java?
A) To create objects
B) To initialize variables
C) To define methods
D) To perform calculations
50. How is an object created in Java?
A) Using the new keyword
B) Using the create keyword
C) Using the instantiate keyword
D) Using the object keyword
51. Inheritance in Java allows a class to ________.
A) Be instantiated
B) Extend another class
C) Create multiple objects
D) Define abstract methods
52. Which keyword is used to implement inheritance in Java?
A) extend
B) inherit
C) include
D) expand
53. What is an array in Java?
A) A collection of similar elements
B) A collection of different elements
C) A single element
D) A predefined data type
54. How is a one-dimensional array declared in Java?
A) int[] array;
B) array[] int;
C) array int[];
D) int array[];
55. How are elements accessed in a one-dimensional array?
A) Using dot notation
B) Using parentheses
C) Using square brackets
D) Using curly braces
56. Which of the following is true about a two-dimensional array?
A) It has only one row
B) It has only one column
C) It has multiple rows and columns
D) It cannot store integers

57. What is the purpose of the length property of an array in Java?


A) To return the size of the array
B) To return the first element of the array
C) To return the last element of the array
D) To return the sum of all elements in the array
58. Which class is used to manipulate strings in Java?
A) StringManipulator
B) TextHandler
C) String
D) StringBuilder
59. Which method is used to concatenate strings in Java?
A) concat()
B) merge()
C) append()
D) join()
60. What is the difference between String and StringBuffer in Java?
A) String is mutable while StringBuffer is immutable
B) String is immutable while StringBuffer is mutable
C) Both String and StringBuffer are mutable
D) Both String and StringBuffer are immutable
61. Which of the following is a wrapper class in Java?
A) String
B) int
C) boolean
D) double
62. Which wrapper class is used for integers in Java?
A) Integer
B) Int
C) IntWrapper
D) intWrapper
63. What is autoboxing in Java?
A) Converting primitive types to wrapper objects automatically
B) Converting wrapper objects to primitive types automatically
C) Converting between different wrapper objects automatically
D) Converting between different primitive types automatically
64. Which method is used to convert a string to an integer in Java?
A) toInt()
B) parseInt()
C) integerValue()
D) convertToInt()
65. Which of the following is not a valid constructor declaration?
A) public MyClass() {}
B) public void MyClass() {}
C) public MyClass(int x) {}
D) public MyClass(int x, int y) {}
66. What happens if a class does not define a constructor?
A) It is not possible to create objects of that class
B) The compiler generates a default constructor
C) The class cannot have methods
D) The class cannot have variables
67. Which of the following keywords is used to call the constructor of the superclass?
A) super()
B) this()
C) extends
D) implements
68. Which of the following statements is true about method overloading?
A) It is not allowed in Java
B) Methods must have the same name and return type
C) Methods must have different names but the same parameter types
D) Methods must have the same name but different parameter types
69. Which of the following is not a valid access modifier in Java?
A) private
B) protected
C) default
D) public
70. What is the default access modifier in Java?
A) private
B) protected
C) default
D) public
71. Which keyword is used to prevent a method from being overridden in Java?
A) final
B) static
C) const
D) override
72. Which of the following is not a valid method signature in Java?
A) void myMethod()
B) int myMethod(int x)
C) String myMethod(String s)
D) double myMethod(int x, int y)
73. Which of the following statements is true about the main method in Java?
A) It is required in every class
B) It must return a value
C) It must be declared as static
D) It can have any access modifier
74. Which keyword in Java is used to implement inheritance?
a) extends
b) implements
c) inheritance
d) using
75. What is the default superclass for all classes in Java?
a) Superclass
b) ParentClass
c) Object
d) BaseClass
76. Which keyword is used to access the superclass constructor in Java?
a) super()
b) this()
c) parent()
d) base()
77. What is the highest level of inheritance in Java?
a) Single inheritance
b) Multilevel inheritance
c) Hierarchical inheritance
d) Multiple inheritance
78. Which keyword is used to declare a class as abstract in Java?
a) abstract
b) class
c) abstract class
d) final
79. What is the use of the final keyword in Java?
a) To prevent inheritance
b) To prevent method overriding
c) To prevent object creation
d) All of the above
80. Which class serves as the root of the class hierarchy in Java?
a) Main
b) Root
c) Object
d) Base Answer
81. What is the purpose of packages in Java?
a) To organize classes and interfaces
b) To improve code reusability
c) To avoid naming conflicts
d) All of the above
82. Which access modifier restricts access the least in Java?
a) public b) private c) protected d) default
83. Can interfaces be extended in Java?
a) Yes b) No c) Only in certain cases d) Only by abstract classes
84. Which keyword is used to handle exceptions in Java?
a) try b) catch c) throw d) finally
85. Which of the following is a checked exception in Java?
a) NullPointerException b) ArrayIndexOutOfBoundsException c) FileNotFoundException d)
ArithmeticException
86. What happens if an uncaught exception occurs in Java?
a) Program terminates abnormally b) Program continues execution c) Program prints an error
message d) Program waits for user input
87. When is the throw keyword used in Java?
a) To declare a new exception b) To rethrow an exception c) To explicitly throw an exception d)
All of the above
88. Which keyword is used to prevent method overriding in Java?
a) prevent b) final c) override d) static
89. Which of the following is a built-in exception in Java?
a) CustomException b) IOException c) ApplicationException d) UserException
90. How can you create your own custom exception in Java?
a) By extending Exception class b) By implementing Throwable interface c) By using the throw
keyword d) By using the catch keyword
91. Which keyword is used to declare an interface in Java?
a) interface b) class c) implements d) extends
92. What is the purpose of the extends keyword in Java?
a) To implement inheritance b) To implement polymorphism c) To implement encapsulation d) To
implement abstraction
93. Which of the following is a runtime exception in Java?
a) NullPointerException b) ClassNotFoundException c) IOException d) FileNotFoundException
94. Which type of exception does not need to be declared in a method's throws clause?
a) Checked exception b) Unchecked exception c) Runtime exception d) All exceptions need to be
declared
95. In a multilevel inheritance hierarchy, a subclass inherits from __________.
a) One superclass b) Multiple superclasses c) Grandparent class d) All of the above
96. In Java, how can you prevent a class from being subclassed?
a) Using final keyword b) Using abstract keyword c) Using static keyword d) All classes can be
subclassed in Java
97. Which keyword is used to throw an exception manually in Java?
a) try b) catch c) throw d) throws
98. Which of the following is a correct syntax for declaring a package in Java?
a) package com.example; b) package example.com; c) import com.example.*; d) using
com.example;
99. What is the difference between throw and throws in Java?
a) throw is used to throw an exception, whereas throws is used to declare exceptions. b) throw is
used to declare exceptions, whereas throws is used to throw an exception. c) Both are used
interchangeably. d) There is no difference.
100. Which keyword is used to implement interface inheritance in Java?
a) extend b) implements c) extends d) inheritance
101. Which of the following statements about packages in Java is true?
a) Packages can only contain classes, not interfaces. b) Packages can contain both classes and
interfaces. c) Packages can only be defined in the main class. d) Packages are automatically
imported into every Java program.
102. Which of the following exceptions is a checked exception in Java?
a) ArrayIndexOutOfBoundsException b) NullPointerException c) IOException d)
ArithmeticException
103. In Java, how do you create a user-defined exception?
a) By extending the Exception class b) By implementing the Throwable interface c) By using the
catch keyword d) By using the throw keyword
104. What is multithreading?
a) Executing multiple processes simultaneously b) Executing multiple tasks simultaneously within
a process c) Executing a single task in multiple threads d) Executing multiple tasks sequentially
105. Which model does Java use for multithreading?
a) Co-operative model b) Pre-emptive model c) Hybrid model d) Sequential model
106. What is the purpose of thread priorities in Java?
a) To determine the order of thread execution b) To allocate more resources to higher priority
threads c) To ensure fairness in thread scheduling d) To prevent deadlocks
107. Which keyword in Java is used for synchronization?
a) sync b) synchronize c) locked d) thread
108. What is the purpose of synchronization in multithreaded programming?
a) To speed up execution b) To prevent race conditions c) To create deadlock situations d) To
make threads independent of each other
109. Which interface must be implemented to create a thread in Java?
a) Thread b) Runnable c) Executor d) Concurrent
110. How can threads communicate with each other in Java?
a) Using shared memory b) Using message passing c) Using thread identifiers d) Using
synchronization only
111. Which method is used to suspend a thread in Java?
a) sleep() b) suspend() c) pause() d) stop()
112. What is the purpose of the Runnable interface in Java?
a) To create a new thread b) To define a task to be executed by a thread c) To manage thread
priorities d) To synchronize thread execution
113. Which method is used to resume a suspended thread in Java?
a) resume() b) restart() c) start() d) resumeThread()
114. What is the purpose of stopping a thread in Java?
a) To pause its execution temporarily b) To terminate its execution permanently c) To wait for
another thread to complete d) To reset its priority
115. Which framework is used for Object Relational Mapping (ORM) in Java?
a) JDBC b) Hibernate c) Spring d) JPA
116. What does ORM stand for?
a) Object-Relational Model b) Object-Relational Mapping c) Object-Relation Model d) Object-
Relation Mapping
117. What is the purpose of Hibernate configuration file (hibernate.cfg.xml)?
a) To define database schema b) To specify SQL queries c) To configure Hibernate settings d) To
define Java classes
118. What is HQL in Hibernate?
a) Hibernate Query Language b) High-Quality Language c) Hibernate Quick Language d) High-
Quality Library
119. How do you make objects persistent in Hibernate?
a) By serializing them b) By storing them in a file c) By mapping them to database tables d) By
using object references
120. What does the Hibernate Session represent?
a) A database connection b) A unit of work c) A transaction d) A query result set
121. What is flushing in Hibernate?
a) Writing changes to the database b) Clearing the session cache c) Deleting objects from
memory d) Refreshing object state
122. What is concurrency in the context of Hibernate?
a) Simultaneous execution of multiple database transactions b) Parallel execution of Hibernate
queries c) Handling multiple users in a database system d) Coordinating multiple threads
accessing shared resources
123. What is optimistic locking in Hibernate?
a) Locking objects based on their priority b) Locking objects when they are accessed c) Allowing
multiple transactions to access the same data d) Checking for conflicts only at the time of update
124. What is pessimistic locking in Hibernate?
a) Locking objects based on their priority b) Locking objects when they are accessed c)
Preventing multiple transactions from accessing the same data d) Checking for conflicts only at
the time of update
125. Which method is used to lock an object for pessimistic locking in Hibernate?
a) lock() b) pessimisticLock() c) acquireLock() d) obtainLock()
126. Which of the following is true about Hibernate?
a) It is a programming language b) It is a relational database management system c) It is an ORM
framework d) It is a web server
127. What is the primary purpose of the Hibernate SessionFactory?
a) To manage database connections b) To manage Hibernate sessions c) To configure Hibernate
settings d) To load Hibernate mappings
128. Which of the following is not a valid Hibernate mapping association?
a) @OneToOne b) @OneToMany c) @ManyToMany d) @OneToAll

129. What is the purpose of lazy loading in Hibernate?


a) To load all associated objects eagerly b) To defer the loading of associated objects until they
are accessed c) To load only a subset of associated objects d) To load associated objects in
parallel
130. Which of the following is not a fundamental concept in multithreaded programming?
A) Priorities B) Synchronization C) Inheritance D) Messaging
131. In Java, what interface is used to implement multithreading by creating a new thread?
A) Thread B) Process C) Executor D) Runnable
132. What does the Java Thread model provide?
A) Support for parallel processing B) Mechanism for defining threads C) Interprocess
communication D) Automatic memory management
133. Which method is used to set the priority of a thread in Java?
A) setPriority() B) setThreadPriority() C) priority() D) threadPriority()
134. Which keyword is used for thread synchronization in Java?
A) sync B) thread C) synchronized D) lock
135. What is the primary purpose of synchronization in multithreaded programming?
A) To increase thread priority B) To avoid race conditions C) To suspend threads D) To increase
thread efficiency
136. Which class in Java represents a thread?
A) Thread B) Runnable C) Executor D) Processor
137. What interface must be implemented for any object intending to execute as a thread in
Java? A) Executor B) Processor C) Runnable D) Threadable
138. How can threads communicate with each other in Java?
A) Using global variables B) Using synchronization C) Using thread identifiers D) Using local
variables
139. What is the purpose of suspending a thread in Java?
A) To stop the thread permanently B) To pause the execution temporarily C) To resume execution
from the beginning D) To increase thread priority
140. Which method is used to resume a suspended thread in Java?
A) resume() B) start() C) interrupt() D) notify()
141. What is the primary purpose of stopping a thread in Java?
A) To pause the execution temporarily B) To terminate the thread permanently C) To increase
thread priority D) To release system resources
142. What is Hibernate primarily used for?
A) Multithreaded programming B) Object-relational mapping C) Message passing D)
Synchronization
143. What is the configuration file used in Hibernate called?
A) hibernate-config.xml B) hibernate.properties C) hibernate.cfg.xml D) hibernate.conf
144. What language is used for querying in Hibernate?
A) SQL B) Java C) HQL D) XML
145. Which of the following is responsible for making Java objects persistent in Hibernate?
A) Hibernate Query Language (HQL) B) Hibernate Session C) Hibernate Criteria API D) Hibernate
Configuration
146. What does Hibernate provide for managing database transactions?
A) Criteria API B) Session Management C) Connection Pooling D) Data Persistence
147. What is the purpose of flushing in Hibernate?
A) To synchronize threads B) To release system resources C) To execute pending SQL statements
D) To optimize database access
148. What is concurrency control in Hibernate primarily concerned with?
A) Managing thread priorities B) Preventing race conditions C) Ensuring database consistency D)
Optimizing database queries
149. What locking mechanism in Hibernate assumes that conflicts between transactions are
rare and allows transactions to proceed without waiting?
A) Optimistic Locking B) Pessimistic Locking C) Read Locking D) Write Locking
150. In Java, which method is used to make a thread sleep for a specified amount of time?
A) wait() B) sleep() C) hold() D) pause()
151. Which of the following is not a state of a thread in Java?
A) Terminated B) Suspended C) Running D) Waiting
152. What happens when a thread is interrupted in Java?
A) The thread is paused B) The thread is terminated C) The thread is put to sleep D) An exception
is thrown
153. Which method is used to explicitly wait for a thread to die in Java?
A) join() B) wait() C) sleep() D) notify()
154. What does the yield() method in Java do?
A) Suspends the currently executing thread B) Resumes the currently executing thread C)
Relinquishes the CPU so that other threads can execute D) Stops the currently executing thread
155. Which class provides a way to control a thread's execution?
A) ThreadController B) ThreadGroup C) ThreadMonitor D) ThreadManager
156. What is a thread's priority used for in Java?
A) To determine the order of thread execution B) To allocate more resources to high priority
threads C) To pause a thread's execution D) To synchronize threads
157. Which of the following is true about the wait() method in Java?
A) It must be called within a synchronized block B) It releases the lock on the object C) It can only
be called on a thread object D) It throws an InterruptedException What is the purpose of the
notifyAll() method in Java? A) To notify all threads waiting on a particular object B) To notify a
specific thread C) To interrupt
158. Which of the following best describes multithreaded programming?
A) A programming paradigm where multiple threads execute independently within a single
process. B) A programming paradigm where threads execute only in sequence within a single
process. C) A programming paradigm where threads execute in parallel within separate
processes. D) A programming paradigm where threads execute independently within separate
processes.
159. In the Java thread model, what is a thread?
A) A lightweight process that runs within a process. B) A heavy-weight process that runs
independently. C) A function that executes in the background. D) A piece of code that is
executed sequentially.
160. What is the purpose of thread priorities in Java?
A) To determine the order in which threads are executed. B) To allocate system resources to
threads. C) To ensure synchronization between threads. D) To assign weights to threads based on
their importance.
161. Which mechanism is used in Java to synchronize access to shared resources among
multiple threads?
A) Locks B) Mutexes C) Synchronization blocks D) All of the above
162. Which package in Java provides classes and interfaces for networking?
A) java.net B) java.io C) java.lang D) java.util
163. What is the purpose of the java.io package?
A) For networking operations B) For input and output operations C) For exception handling D)
For event handling
164. Which type of streams are used for reading and writing binary data in Java?
A) Byte streams B) Character streams C) Object streams D) Predefined streams
165. What is the main purpose of the java.io.BufferedReader class?
A) Reading binary data from files B) Reading character data from files C) Reading input from the
console D) Writing binary data to files
166. Which package in Java provides classes and interfaces for handling exceptions?
A) java.net B) java.lang C) java.util D) java.exception
167. What is the primary use of the java.lang.Exception class?
A) For event handling B) For synchronization C) For handling errors and exceptional conditions D)
For networking operations
168. Which package in Java provides classes and interfaces for event handling?
A) java.util B) java.awt C) java.event D) java.lang
169. Which of the following is NOT a predefined stream in Java?
A) System.in B) System.out C) System.err D) System.log
170. Which method is used to establish a TCP connection in Java networking?
A) connect() B) bind() C) accept() D) listen()
171. Which class in Java represents a TCP/IP socket?
A) Socket B) ServerSocket C) DatagramSocket D) InetAddress
172. What is the purpose of the java.net.ServerSocket class?
A) For connecting to a server B) For creating server-side sockets C) For sending datagrams D) For
reading from a server
173. Which of the following is true about Datagram programming in Java?
A) It uses TCP for communication. B) It is connection-oriented. C) It is connectionless. D) It is
synchronous.
174. Which package in Java provides classes and interfaces for Bluetooth programming?
A) java.net B) java.bluetooth C) javax.bluetooth D) java.util
175. What is the architecture used in J2ME (Java 2 Platform, Micro Edition)?
A) Monolithic kernel B) Microkernel C) Microservice architecture D) Microarchitecture
176. Which of the following is NOT a standard Java package?
A) java.lang B) java.net C) java.io D) java.awt.event
177. What is the primary purpose of the java.util package?
A) For input and output operations B) For handling exceptions C) For event handling D) For utility
functions
178. Which class in Java is used for handling streams of characters?
A) InputStreamReader B) OutputStreamWriter C) FileReader D) FileWriter
179. What is the purpose of the java.io.DataInputStream class?
A) For reading primitive data types from an input stream B) For reading character data from a file
C) For reading binary data from a file D) For writing primitive data types to a file
180. In Java, what is the purpose of the java.io.DataOutputStream class?
A) For writing primitive data types to a file B) For writing character data to a file C) For reading
binary data from a file D) For reading primitive data types from an input stream

181. Which class in Java is used for reading text from a character-input stream?
A) FileReader B) BufferedReader C) InputStreamReader D) FileWriter
182. What is the purpose of the java.io.BufferedWriter class?
A) For reading text from a character-input stream B) For writing text to a character-output
stream C) For reading binary data from a file D) For writing binary data to a file
183. Which of the following is NOT a predefined stream in Java?
A) Standard.in B) Standard.out C) Standard.err D) Standard.log
184. Which package in Java provides classes and interfaces for handling networking
operations?
A) java.net B) java.io C) java.lang D) java.util
185. What is the primary purpose of the Delegation Event Model in Java?
A) To handle events through delegation B) To model delegation in object-oriented programming
C) To manage event listeners efficiently D) To facilitate communication between objects
186. Which of the following represents an event class in Java?
A) ActionListener B) AbstractWindowAdapter C) EventHandler D) EventManager
187. Which interface should a class implement to handle action events in Java?
A) ActionListener B) EventHandler C) EventListener D) ActionListenerInterface
188. Which Java concept is used to provide default implementations for listeners?
A) Delegation B) Inheritance C) Adapter classes D) Abstract classes
189. Which of the following is NOT an inner class type in Java?
A) Static inner class B) Non-static inner class C) Local inner class D) Global inner class
190. What is the primary purpose of AWT controls in Java?
A) To manage data flow in a program B) To provide a graphical user interface C) To handle
networking tasks D) To implement sorting algorithms
191. Which layout manager is suitable for creating resizable components in Java?
A) BorderLayout B) FlowLayout C) GridLayout D) CardLayout
192. Which Java class is used to represent images?
A) Image B) ImageIcon C) ImageLoader D) ImageProcessor
193. Which of the following is used to handle animation in Java?
A) Thread B) Timer C) ExecutorService D) Semaphore
194. What is the purpose of Java Applets?
A) To create standalone desktop applications B) To provide dynamic content on web pages C) To
handle database operations D) To manage server-side scripting
195. What is the primary role of the Spring Framework in Java development?
A) To provide a standardized way to build enterprise applications B) To handle graphical user
interface components C) To manage database connections D) To create mobile applications
196. Which architectural pattern is commonly associated with the Spring Framework?
A) Model-View-Controller (MVC) B) Observer C) Singleton D) Prototype
197. What is the primary role of the Bean Factory in Spring Framework?
A) To manage beans and their dependencies B) To handle user authentication C) To provide
encryption services D) To execute batch processing tasks

198. Which package in Java provides classes and interfaces for handling exceptions?
A) java.net B) java.lang C) java.util D) java.exception

199. What is flushing in Hibernate?


a) Writing changes to the database b) Clearing the session cache c) Deleting objects from
memory d) Refreshing object state

You might also like