

MCQOPTIONS
This section includes 219 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.
151. |
Which of the following statements about the hashcode() method are incorrect?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 1 and 4 |
Answer» C. 3 and 4 | |
152. |
What will be the output of the program?
|
A. | 42 |
B. | 42.5 |
C. | 43 |
D. | bad number |
Answer» D. bad number | |
153. |
What will be the output of the program?
|
A. | 0 1 2 |
B. | 1 2 3 |
C. | 0 1 2 3 |
D. | 1 2 3 4 |
E. | Compilation fails |
Answer» F. | |
154. |
What will be the output of the program?
|
A. | Base |
B. | BaseBase |
C. | Compilation fails |
D. | The code runs with no output |
Answer» C. Compilation fails | |
155. |
What will be the output of the program?
|
A. | 0 2 4 |
B. | 0 2 4 6 |
C. | Compilation fails at line 2 |
D. | Compilation fails at line 10 |
Answer» E. | |
156. |
What will be the output of the program?
|
A. | 4, 4 |
B. | 4, 5 |
C. | 5, 4 |
D. | Compilation fails. |
Answer» E. | |
157. |
and assuming that the equals() and hashCode() methods are properly implemented, if the output is "x = 1111", which of the following statements will always be true?
|
A. | x2.equals(x1) |
B. | x3.hashCode() == x4.hashCode() |
C. | x5.hashCode() != x6.hashCode() |
D. | x8.equals(x7) |
Answer» C. x5.hashCode() != x6.hashCode() | |
158. |
Which of the following are true statements?
|
A. | 2, 3, 4 and 5 |
B. | 1, 3, 4 and 5 |
C. | 3, 4 and 5 |
D. | 1, 2 and 3 |
Answer» C. 3, 4 and 5 | |
159. |
Which statement is true for the class java.util.ArrayList? |
A. | The elements in the collection are ordered. |
B. | The collection is guaranteed to be immutable. |
C. | The elements in the collection are guaranteed to be unique. |
D. | The elements in the collection are accessed using a unique key. |
Answer» B. The collection is guaranteed to be immutable. | |
160. |
What will be the output of the program? System.out.println(Math.sqrt(-4D)); |
A. | -2 |
B. | NaN |
C. | Compile Error |
D. | Runtime Exception |
Answer» C. Compile Error | |
161. |
What will be the output of the program?
|
A. | apa |
B. | app |
C. | apea |
D. | apep |
Answer» C. apea | |
162. |
What will be the output of the program?
|
A. | abcdefghi |
B. | abcdefdef |
C. | abcghidef |
D. | abcghighi |
Answer» D. abcghighi | |
163. |
What will be the output of the program?
|
A. | j = 0 |
B. | j = 4 |
C. | j = 8 |
D. | The code will run with no output |
Answer» C. j = 8 | |
164. |
What will be the output of the program?
|
A. | 9.0 |
B. | bad number |
C. | Compilation fails on line 9. |
D. | Compilation fails on line 11. |
Answer» B. bad number | |
165. |
What will be the output of the program?
|
A. | 18 |
B. | 117 |
C. | 567 |
D. | Compiler error |
Answer» C. 567 | |
166. |
What will be the output of the program?
|
A. | 3.0 |
B. | -3.0 |
C. | NaN |
D. | Compilation fails. |
Answer» D. Compilation fails. | |
167. |
What will be the output of the program?
|
A. | ABC |
B. | abc |
C. | ABCdef |
D. | Compile Error |
Answer» D. Compile Error | |
168. |
What will be the output of the program?
|
A. | ACCBAD |
B. | ABBCAD |
C. | CDDACB |
D. | Indeterminate output |
Answer» E. | |
169. |
What will be the output of the program?
|
A. | 1 and 3 |
B. | 2 and 4 |
C. | 3 and 4 |
D. | 1 and 2 |
Answer» B. 2 and 4 | |
170. |
What will be the output of the program (in jdk1.6 or above)?
|
A. | z |
B. | x z |
C. | <!--<p> Answer:The compiler fails at line 13 because b1 is a reference variable to a <i class="java-code">Boolean</i> wrapper object, not a boolean primitive. Logical boolean tests can't be made on <i class="java-code">Boolean</i> objects.</p> --> |
D. | y z |
E. | Compilation fails. |
Answer» C. <!--<p> Answer:The compiler fails at line 13 because b1 is a reference variable to a <i class="java-code">Boolean</i> wrapper object, not a boolean primitive. Logical boolean tests can't be made on <i class="java-code">Boolean</i> objects.</p> --> | |
171. |
What will be the output of the program?
|
A. | java |
B. | javac |
C. | javajavac |
D. | Compile error |
Answer» D. Compile error | |
172. |
What will be the output of the program?
|
A. | Pine |
B. | Tree |
C. | Forest |
D. | Oops |
Answer» B. Tree | |
173. |
What will be the output of the program?
|
A. | wookkeewoo |
B. | wbookkeeper |
C. | wbookkeewoo |
D. | Compilation fails. |
Answer» E. | |
174. |
What will be the output of the program?
|
A. | abcd |
B. | ABCD |
C. | dccd |
D. | dcba |
Answer» B. ABCD | |
175. |
What will be the output of the program?
|
A. | 1 |
B. | 2 |
C. | 3 |
D. | Compilation Fails |
Answer» E. | |
176. |
What will be the output of the program?
|
A. | AAACCC |
B. | AAADDD |
C. | BBBCCC |
D. | BBBDDD |
Answer» B. AAADDD | |
177. |
What will be the output of the program?
|
A. | abcXyZ |
B. | abcxyz |
C. | xyzabc |
D. | XyZabc |
Answer» D. XyZabc | |
178. |
What will be the output of the program?
|
A. | i = 0 |
B. | i = 1 |
C. | value of i is undetermined |
D. | Statement causes a compile error |
Answer» B. i = 1 | |
179. |
What will be the output of the program?
|
A. | It compiles and runs printing nothing |
B. | Compiles but fails at runtime |
C. | Compile Error |
D. | Prints "complete" |
Answer» D. Prints "complete" | |
180. |
What will be the output of the program?
|
A. | i = 6 and j = 5 |
B. | i = 5 and j = 5 |
C. | i = 6 and j = 6 |
D. | i = 5 and j = 6 |
Answer» E. | |
181. |
What two statements are true about properly overridden hashCode() and equals() methods?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 1 and 3 |
Answer» D. 1 and 3 | |
182. |
Which two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden?
|
A. | 1 and 4 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 1 and 3 |
Answer» B. 2 and 3 | |
183. |
Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence? |
A. | java.util.ArrayList |
B. | java.util.LinkedHashMap |
C. | java.util.HashMap |
D. | java.util.TreeMap |
Answer» C. java.util.HashMap | |
184. |
Which interface provides the capability to store objects using a key-value pair? |
A. | Java.util.Map |
B. | Java.util.Set |
C. | Java.util.List |
D. | Java.util.Collection |
Answer» B. Java.util.Set | |
185. |
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization? |
A. | java.util.SortedMap |
B. | java.util.TreeMap |
C. | java.util.TreeSet |
D. | java.util.Hashtable |
Answer» E. | |
186. |
Which is valid declaration of a float? |
A. | float f = 1F; |
B. | float f = 1.0; |
C. | float f = "1"; |
D. | float f = 1.0d; |
Answer» B. float f = 1.0; | |
187. |
What line of code should replace the missing statement to make this program compile?
|
A. | No statement required. |
B. | import java.io.*; |
C. | include java.io.*; |
D. | import java.io.PrintWriter; |
Answer» B. import java.io.*; | |
188. |
What is the numerical range of char? |
A. | 0 to 32767 |
B. | 0 to 65535 |
C. | -256 to 255 |
D. | -32768 to 32767 |
Answer» C. -256 to 255 | |
189. |
Which of the following are Java reserved words?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 2 and 4 |
Answer» C. 3 and 4 | |
190. |
which two code fragments inserted at end of the program, will allow to compile?
|
A. | 1 only |
B. | 2 only |
C. | 3 and 5 |
D. | 1 and 4 |
Answer» D. 1 and 4 | |
191. |
Which two statements are true for any concrete class implementing the java.lang.Runnable interface?
|
A. | 1 and 3 |
B. | 2 and 4 |
C. | 1 and 5 |
D. | 2 and 6 |
Answer» E. | |
192. |
which two statements, added independently at beginning of the program, allow the code to compile?
|
A. | 1 only |
B. | 2 and 5 |
C. | 3 and 4 |
D. | 3 and 5 |
Answer» C. 3 and 4 | |
193. |
Which three statements are true?
|
A. | 1, 2 and 4 |
B. | 2, 3 and 5 |
C. | 3, 4 and 5 |
D. | 1, 2 and 3 |
Answer» C. 3, 4 and 5 | |
194. |
which statement is true?
|
A. | The code compiles and runs, with output this 420 parent 420. |
B. | If line 18 is removed, the code will compile and run. |
C. | If line 20 is removed, the code will compile and run. |
D. | An exception is thrown at runtime. |
Answer» D. An exception is thrown at runtime. | |
195. |
Which three are valid method signatures in an interface?
|
A. | 1 and 2 |
B. | 2, 3 and 5 |
C. | 3, 4, and 5 |
D. | 2 and 4 |
Answer» C. 3, 4, and 5 | |
196. |
What will be the output of the program? How many String objects have been created?
|
A. | 2 |
B. | 3 |
C. | 4 |
D. | 5 |
Answer» D. 5 | |
197. |
What will be the output of the program?
|
A. | result = 1 |
B. | result = 10 |
C. | result = 11 |
D. | result = 11010 |
Answer» C. result = 11 | |
198. |
What will be the output of the program?
|
A. | 0 |
B. | 1 |
C. | 10 |
D. | 10010 |
Answer» E. | |
199. |
What will be the output of the program?
|
A. | 1 |
B. | 10 |
C. | 101 |
D. | 1101 |
Answer» E. | |
200. |
What will be the output of the program?
|
A. | same results 0 time(s) |
B. | same results 2 time(s) |
C. | same results 4 time(s) |
D. | Compilation fails. |
Answer» C. same results 4 time(s) | |