

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.
201. |
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective? |
A. | public |
B. | private |
C. | protected |
D. | default access |
Answer» E. | |
202. |
Which statement is true given the following? Double d = Math.random(); |
A. | 0.0 < d <= 1.0 |
B. | 0.0 <= d < 1.0 |
C. | Compilation fail |
D. | Cannot say. |
Answer» C. Compilation fail | |
203. |
Which two statements are true about wrapper or String classes?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 4 and 5 |
Answer» E. | |
204. |
Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d? |
A. | (int)Math.min(d); |
B. | (int)Math.max(d); |
C. | (int)Math.abs(d); |
D. | (int)Math.floor(d); |
Answer» E. | |
205. |
What two statements are true about the result obtained from calling Math.random()?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 4 and 5 |
Answer» C. 3 and 4 | |
206. |
Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance? |
A. | TreeMap |
B. | HashMap |
C. | LinkedHashMap |
D. | The answer depends on the implementation of the existing instance. |
Answer» D. The answer depends on the implementation of the existing instance. | |
207. |
Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object? |
A. | java.lang.String |
B. | java.lang.Double |
C. | java.lang.StringBuffer |
D. | java.lang.Character |
Answer» D. java.lang.Character | |
208. |
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized? |
A. | java.util.HashSet |
B. | java.util.LinkedHashSet |
C. | java.util.List |
D. | java.util.ArrayList |
Answer» E. | |
209. |
Which interface does java.util.Hashtable implement? |
A. | Java.util.Map |
B. | Java.util.List |
C. | Java.util.HashTable |
D. | Java.util.Collection |
Answer» B. Java.util.List | |
210. |
You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability? |
A. | java.util.Map |
B. | java.util.Set |
C. | java.util.List |
D. | java.util.Collection |
Answer» C. java.util.List | |
211. |
You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective? |
A. | public |
B. | private |
C. | protected |
D. | transient |
Answer» D. transient | |
212. |
Which of the following code fragments inserted, will allow to compile? |
A. | new Inner(); //At line 5 |
B. | new Inner(); //At line 10 |
C. | new ot.Inner(); //At line 10 |
D. | new Outer.Inner(); //At line 10 |
Answer» B. new Inner(); //At line 10 | |
213. |
What is the value of "d" after this line of code has been executed? double d = Math.round ( 2.5 + Math.random() ); |
A. | 2 |
B. | 3 |
C. | 4 |
D. | 2.5 |
Answer» C. 4 | |
214. |
which two code fragments will compile?
|
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | 1 and 5 |
Answer» D. 1 and 5 | |
215. |
Which three form part of correct array declarations?
|
A. | 1, 3, 4 |
B. | 2, 4, 5 |
C. | 1, 2, 6 |
D. | 2, 5, 6 |
Answer» D. 2, 5, 6 | |
216. |
What is the prototype of the default constructor?
|
A. | Test( ) |
B. | Test(void) |
C. | public Test( ) |
D. | public Test(void) |
Answer» D. public Test(void) | |
217. |
Which of the following would compile without error? |
A. | int a = Math.abs(-5); |
B. | int b = Math.abs(5.0); |
C. | int c = Math.abs(5.5F); |
D. | int d = Math.abs(5L); |
Answer» B. int b = Math.abs(5.0); | |
218. |
Which of the following are valid calls to Math.max?
|
A. | 1, 2 and 4 |
B. | 2, 3 and 4 |
C. | 1, 2 and 3 |
D. | 3 and 4 |
Answer» B. 2, 3 and 4 | |
219. |
Select how you would start the program to cause it to print: Arg is 2
|
A. | java Myfile 222 |
B. | java Myfile 1 2 2 3 4 |
C. | java Myfile 1 3 2 2 |
D. | java Myfile 0 1 2 3 |
Answer» D. java Myfile 0 1 2 3 | |