InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 351. |
Which of the below is an incorrect annotation with respect to JUnits?(a) @Test(b) @BeforeClass(c) @Junit(d) @AfterEach |
|
Answer» The correct option is (c) @Junit Best explanation: @Test is used to annotate method under test, @BeforeEach and @AfterEach are called before and after each method respectively. @BeforeClass and @AfterClass are called only once for each class. |
|
| 352. |
What is Optional object used for?(a) Optional is used for optional runtime argument(b) Optional is used for optional spring profile(c) Optional is used to represent null with absent value(d) Optional means it’s not mandatory for method to return object |
|
Answer» Correct answer is (c) Optional is used to represent null with absent value Explanation: Optional object is used to represent null with absent value. This class has various utility methods to facilitate code to handle values as ‘available’ or ‘not available’ instead of checking null values. |
|
| 353. |
Which of the following is not introduced with Java 8?(a) Stream API(b) Serialization(c) Spliterator(d) Lambda Expression |
|
Answer» Right option is (b) Serialization The explanation: Serialization is not introduced with Java 8. It was introduced with an earlier version of Java. |
|
| 354. |
What type of methods an interface contain by default?(a) abstract(b) static(c) final(d) private |
|
Answer» Right choice is (a) abstract Explanation: By default, interface contains abstract methods. The abstract methods need to be implemented by concrete classes. |
|
| 355. |
What is the substitute of Rhino javascript engine in Java 8?(a) Nashorn(b) V8(c) Inscript(d) Narcissus |
|
Answer» Correct choice is (a) Nashorn Best explanation: Nashorn provides 2 to 10 times faster in terms of performance, as it directly compiles the code in memory and passes the bytecode to JVM. Nashorn uses invoke dynamic feature. |
|
| 356. |
Which of these is not a mocking framework?(a) EasyMock(b) Mockito(c) PowerMock(d) MockJava |
|
Answer» The correct option is (d) MockJava Explanation: EasyMock, jMock, Mockito, Unitils Mock, PowerMock and JMockit are a various mocking framework. |
|
| 357. |
Which of these can be used to differentiate two or more methods having the same name?(a) Parameters data type(b) Number of parameters(c) Return type of method(d) All of the mentioned |
|
Answer» Right option is (d) All of the mentioned The best explanation: None. |
|
| 358. |
Which of these classes is not part of Java’s collection framework?(a) Maps(b) Array(c) Stack(d) Queue |
|
Answer» The correct option is (a) Maps Easy explanation: Maps is not a part of collection framework. |
|
| 359. |
Which of the below is not a javascript framework for UI?(a) Vaadin(b) AngularJS(c) KendoUI(d) Springcore |
|
Answer» Correct answer is (d) Springcore For explanation I would say: Springcore is not a javascript framework. It is a comprehensive programming and configuration model for enterprise applications based on java. |
|
| 360. |
Which of this interface is not a part of Java’s collection framework?(a) List(b) Set(c) SortedMap(d) SortedList |
|
Answer» Correct option is (d) SortedList The explanation: SortedList is not a part of collection framework. |
|
| 361. |
Which of these return type of hasNext() method of an iterator?(a) Integer(b) Double(c) Boolean(d) Collections Object |
|
Answer» Right choice is (c) Boolean For explanation: hasNext() returns boolean values true or false. |
|
| 362. |
Which of these data type can be used for a method having a return statement in it?(a) void(b) int(c) float(d) both int and float |
|
Answer» Right option is (d) both int and float To explain I would say: None. |
|
| 363. |
Which of this method is given parameter via command line arguments?(a) main()(b) recursive() method(c) Any method(d) System defined methods |
|
Answer» Correct option is (a) main() To explain: Only main() method can be given parameters via using command line arguments. |
|
| 364. |
Which of these class object uses the key to store value?(a) Dictionary(b) Map(c) Hashtable(d) All of the mentioned |
|
Answer» Right choice is (d) All of the mentioned To explain I would say: Dictionary, Map & Hashtable all implement Map interface hence all of them uses keys to store value in the object. |
|
| 365. |
What is the name of a data member of class Vector which is used to store a number of elements in the vector?(a) length(b) elements(c) elementCount(d) capacity |
|
Answer» Right option is (c) elementCount Best explanation: None. |
|
| 366. |
Which of these data types is used to store command line arguments?(a) Array(b) Stack(c) String(d) Integer |
|
Answer» The correct option is (c) String Easiest explanation: None. |
|
| 367. |
Which of these is a class which uses String as a key to store the value in object?(a) Array(b) ArrayList(c) Dictionary(d) Properties |
|
Answer» Right choice is (d) Properties The explanation is: None. |
|
| 368. |
Which of these methods is used to retrieve the elements in properties object at specific location?(a) get()(b) Elementat()(c) ElementAt()(d) getProperty() |
|
Answer» Right answer is (d) getProperty() Easiest explanation: None. |
|
| 369. |
What is true about do statement?(a) do statement executes the code of a loop at least once(b) do statement does not get execute if condition is not matched in the first iteration(c) do statement checks the condition at the beginning of the loop(d) do statement executes the code more than once always |
|
Answer» Right choice is (a) do statement executes the code of a loop at least once Easiest explanation: Do statement checks the condition at the end of the loop. Hence, code gets executed at least once. |
|
| 370. |
From where break statement causes an exit?(a) Only from innermost loop(b) Terminates a program(c) Only from innermost switch(d) From innermost loops or switches |
|
Answer» The correct choice is (d) From innermost loops or switches For explanation I would say: The break statement causes an exit from innermost loop or switch. |
|
| 371. |
What is true about a break?(a) Break stops the execution of entire program(b) Break halts the execution and forces the control out of the loop(c) Break forces the control out of the loop and starts the execution of next iteration(d) Break halts the execution of the loop for certain time frame |
|
Answer» Correct choice is (b) Break halts the execution and forces the control out of the loop For explanation: Break halts the execution and forces the control out of the loop. |
|
| 372. |
Which of the following is not a valid jump statement?(a) break(b) goto(c) continue(d) return |
|
Answer» The correct choice is (b) goto For explanation I would say: break, continue and return transfer control to another part of the program and returns back to caller after execution. However, goto is marked as not used in Java. |
|
| 373. |
Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?(a) break(b) return(c) exit(d) continue |
|
Answer» Correct option is (d) continue To elaborate: None. |
|
| 374. |
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?(a) do-while(b) while(c) for(d) none of the mentioned |
|
Answer» Right option is (a) do-while To elaborate: None. |
|
| 375. |
How to remove duplicates from List?(a) HashSet listToSet = new HashSet(duplicateList);(b) HashSet listToSet = duplicateList.toSet();(c) HashSet listToSet = Collections.convertToSet(duplicateList);(d) HashSet listToSet = duplicateList.getSet(); |
|
Answer» Correct option is (a) HashSet Explanation: Duplicate elements are allowed in List. Set contains unique objects. |
|
| 376. |
If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?(a) rear=(rear%1)+MAX_SIZE(b) rear=(rear+1)%MAX_SIZE(c) rear=rear+(1%MAX_SIZE)(d) rear=rear%(MAX_SIZE+1) |
|
Answer» The correct choice is (b) rear=(rear+1)%MAX_SIZE The explanation is: The front and rear pointer od circular queue point to the first element. |
|
| 377. |
What is the difference between Queue and Stack?(a) Stack is LIFO; Queue is FIFO(b) Queue is LIFO; Stack is FIFO(c) Stack and Queue is FIFO(d) Stack and Queue is LIFO |
|
Answer» Right answer is (a) Stack is LIFO; Queue is FIFO To explain: Stack is Last in First out (LIFO) and Queue is First in First out(FIFO). |
|
| 378. |
What are the use of front and rear pointers in CircularQueue implementation?(a) Front pointer points to first element; rear pointer points to the last element(b) Rear pointer points to first element; front pointer points to the last element(c) Front and read pointers point to the first element(d) Front pointer points to the first element; rear pointer points to null object |
|
Answer» Right answer is (c) Front and read pointers point to the first element For explanation: CircularQueue implementation is an abstract class where first and rear pointer point to the same object. |
|