MCQOPTIONS
Saved Bookmarks
This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of these type parameters is used for a generic methods to return and accept a number? |
| A. | K |
| B. | N |
| C. | T |
| D. | V |
| Answer» C. T | |
| 2. |
Which of these type parameters is used for a generic methods to return and accept any type of object? |
| A. | K |
| B. | N |
| C. | T |
| D. | V |
| Answer» D. V | |
| 3. |
What are generic methods? |
| A. | Generic methods are the methods defined in a generic class |
| B. | Generic methods are the methods that extend generic class methods |
| C. | Generic methods are methods that introduce their own type parameters |
| D. | Generic methods are methods that take void parameters |
| Answer» D. Generic methods are methods that take void parameters | |
| 4. |
Which is better in terms of performance for iterating an array? |
| A. | for(int i=0; i<100; i++) |
| B. | for(int i=99; i>=0; i–) |
| C. | for(int i=100; i<0; i++) |
| D. | for(int i=99; i>0; i++) |
| Answer» C. for(int i=100; i<0; i++) | |
| 5. |
Which of the below is false about java coding? |
| A. | variable names should be short |
| B. | variable names should be such that they avoid ambiguity |
| C. | test case method names should be created as english sentences without spaces |
| D. | class constants should be used when we want to share data between class methods |
| Answer» B. variable names should be such that they avoid ambiguity | |
| 6. |
Which of the below is true about java class structure? |
| A. | The class name should start with lowercase |
| B. | The class should have thousands of lines of code |
| C. | The class should only contain those attribute and functionality which it should; hence keeping it short |
| D. | The class attributes and methods should be public |
| Answer» D. The class attributes and methods should be public | |
| 7. |
Which of the following is a best practice to measure time taken by a process for execution? |
| A. | System.currentTimeMillis() |
| B. | System.nanoTime() |
| C. | System.getCurrentTime() |
| D. | System.getProcessingTime() |
| Answer» C. System.getCurrentTime() | |
| 8. |
Which one of the following causes memory leak? |
| A. | Release database connection when querying is complete |
| B. | Use Finally block as much as possible |
| C. | Release instances stored in static tables |
| D. | Not using Finally block often |
| Answer» E. | |
| 9. |
What causes the program to exit abruptly and hence its usage should be minimalistic? |
| A. | Try |
| B. | Finally |
| C. | Exit |
| D. | Catch |
| Answer» D. Catch | |
| 10. |
What data structure should be used when number of elements is fixed? |
| A. | Array |
| B. | Array list |
| C. | Vector |
| D. | Set |
| Answer» B. Array list | |
| 11. |
What should the return type of method where there is no return value? |
| A. | Null |
| B. | Empty collection |
| C. | Singleton collection |
| D. | Empty String |
| Answer» C. Singleton collection | |
| 12. |
What does Liskov substitution principle specify? |
| A. | parent class can be substituted by child class |
| B. | child class can be substituted by parent class |
| C. | parent class cannot be substituted by child class |
| D. | No classes can be replaced by each other |
| Answer» B. child class can be substituted by parent class | |
| 13. |
Which of the following is not an advantage of Hibernate Criteria API? |
| A. | Allows to use aggregate functions. |
| B. | Cannot order the result set. |
| C. | Allows to fetch only selected columns of result. |
| D. | Can add conditions while fetching results. |
| Answer» C. Allows to fetch only selected columns of result. | |
| 14. |
In which file database table configuration is stored? |
| A. | .dbm |
| B. | .hbm |
| C. | .ora |
| D. | .sql |
| Answer» C. .ora | |
| 15. |
Which of the following is not an advantage of using Hibernate Query Language? |
| A. | Database independent |
| B. | Easy to write query |
| C. | No need to learn SQL |
| D. | Difficult to implement |
| Answer» E. | |
| 16. |
Which of the following is not an inheritance mapping strategies? |
| A. | Table per hierarchy |
| B. | Table per concrete class |
| C. | Table per subclass |
| D. | Table per class |
| Answer» E. | |
| 17. |
Which of the following is not a state of object in Hibernate? |
| A. | Attached() |
| B. | Detached() |
| C. | Persistent() |
| D. | Transient() |
| Answer» B. Detached() | |
| 18. |
Which of the following method is used inside session only? |
| A. | merge() |
| B. | update() |
| C. | end() |
| D. | kill() |
| Answer» C. end() | |
| 19. |
Which of the following methods hits database always? |
| A. | load() |
| B. | loadDatabase() |
| C. | getDatabase() |
| D. | get() |
| Answer» E. | |
| 20. |
Which of the following methods returns proxy object? |
| A. | loadDatabase() |
| B. | getDatabase() |
| C. | load() |
| D. | get() |
| Answer» D. get() | |
| 21. |
SessionFactory is a thread-safe object. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 22. |
Which of the following is not a core interface of Hibernate? |
| A. | Configuration |
| B. | Criteria |
| C. | SessionManagement |
| D. | Session |
| Answer» D. Session | |
| 23. |
Which feature of java 7 allows to not explicitly close IO resource? |
| A. | try catch finally |
| B. | IOException |
| C. | Auto Closeable |
| D. | Streams |
| Answer» D. Streams | |
| 24. |
Which jar provides FileUtils which contains methods for file operations? |
| A. | file |
| B. | apache commons |
| C. | file commons |
| D. | dir |
| Answer» C. file commons | |
| 25. |
How can we filter lines based on content? |
| A. | lines.filter() |
| B. | filter(lines) |
| C. | lines.contains(filter) |
| D. | lines.select() |
| Answer» B. filter(lines) | |
| 26. |
How can we create a symbolic link to file? |
| A. | createLink() |
| B. | createSymLink() |
| C. | createSymbolicLink() |
| D. | createTempLink() |
| Answer» D. createTempLink() | |
| 27. |
How to read entire file in one line using java 8? |
| A. | Files.readAllLines() |
| B. | Files.read() |
| C. | Files.readFile() |
| D. | Files.lines() |
| Answer» B. Files.read() | |
| 28. |
How can we get the size of specified file? |
| A. | capacity(path) |
| B. | size(path) |
| C. | length(path) |
| D. | Path.size() |
| Answer» C. length(path) | |
| 29. |
How to copy the file from one location to other? |
| A. | Files.copy(source, target) |
| B. | Path.copy(source, target) |
| C. | source.copy(target) |
| D. | Files.createCopy(target) |
| Answer» B. Path.copy(source, target) | |
| 30. |
How can we delete all files in a directory ? |
| A. | Files.delete(path) |
| B. | Files.deleteDir() |
| C. | Directory.delete() |
| D. | Directory.delete(path) |
| Answer» B. Files.deleteDir() | |
| 31. |
Which method can be used to check fileAccessiblity? |
| A. | isReadable(path) |
| B. | isWritable(path) |
| C. | isExecutable(path) |
| D. | isReadable(path), isWritable(path), and isExecutable(path) |
| Answer» E. | |
| 32. |
Which method is used to create a directory with fileattributes ? |
| A. | Path.create() |
| B. | Path.createDirectory() |
| C. | Files.createDirectory(path, fileAttributes) |
| D. | Files.create(fileAttributes) |
| Answer» D. Files.create(fileAttributes) | |
| 33. |
What does SAM stand for in context of Functional Interface? |
| A. | Single Ambivalue Method |
| B. | Single Abstract Method |
| C. | Simple Active Markup |
| D. | Simple Abstract Markup |
| Answer» C. Simple Active Markup | |
| 34. |
What is the substitute of Rhino javascript engine in java 8? |
| A. | Nashorn |
| B. | V8 |
| C. | Inscript |
| D. | Narcissus |
| Answer» B. V8 | |
| 35. |
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» D. Optional means it’s not mandatory for method to return object | |
| 36. |
What does Files.lines(Path path) do? |
| A. | It reads all the files at the path specified as a String |
| B. | It reads all the lines from a file as a Stream |
| C. | It reads the filenames at the path specified |
| D. | It counts the number of lines for files at the path specified |
| Answer» C. It reads the filenames at the path specified | |
| 37. |
Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target? |
| A. | workPool |
| B. | newWork Stealing Pool |
| C. | thread Pool |
| D. | workThreadPool |
| Answer» C. thread Pool | |
| 38. |
What are the two types of Streams offered by java 8? |
| A. | sequential and parallel |
| B. | sequential and random |
| C. | parallel and random |
| D. | random and synchronized |
| Answer» B. sequential and random | |
| 39. |
Which is the new method introduced in java 8 to iterate over a collection? |
| A. | for (String i : StringList) |
| B. | foreach (String i : StringList) |
| C. | StringList.forEach() |
| D. | List.for() |
| Answer» D. List.for() | |
| 40. |
What is the return type of lambda expression? |
| A. | String |
| B. | Object |
| C. | void |
| D. | function |
| Answer» E. | |
| 41. |
What is the purpose of BooleanSupplier function interface? |
| A. | represents supplier of Boolean-valued results |
| B. | returns Boolean-valued result |
| C. | There is no such function interface |
| D. | returns null if Boolean is passed as argument |
| Answer» B. returns Boolean-valued result | |
| 42. |
Which of the following is not introduced with Java 8? |
| A. | Stream API |
| B. | Serialization |
| C. | Spliterator |
| D. | Lambda Expression |
| Answer» C. Spliterator | |
| 43. |
What is used to inject mock fields into the tested object automatically? |
| A. | @InjectMocks |
| B. | @Inject |
| C. | @InjectMockObject |
| D. | @Mock |
| Answer» B. @Inject | |
| 44. |
How can we simulate if then behavior in Junits? |
| A. | if{..} else{..} |
| B. | if(..){..} else{..} |
| C. | Mockito.when(…).thenReturn(…); |
| D. | Mockito.if(..).then(..); |
| Answer» D. Mockito.if(..).then(..); | |
| 45. |
How to let junits know that they need to be run using PowerMock? |
| A. | @PowerMock |
| B. | @RunWith(PowerMock) |
| C. | @RunWith(Junits) |
| D. | @RunWith(PowerMockRunner.class) |
| Answer» E. | |
| 46. |
What does assertSame() method use for assertion? |
| A. | equals() method |
| B. | isEqual() method |
| C. | == |
| D. | compare() method |
| Answer» D. compare() method | |
| 47. |
Which method is used to verify the actual and expected results in Junits? |
| A. | assert() |
| B. | equals() |
| C. | == |
| D. | isEqual() |
| Answer» B. equals() | |
| 48. |
Which of these is not a mocking framework? |
| A. | EasyMock |
| B. | Mockito |
| C. | PowerMock |
| D. | MockJava |
| Answer» E. | |
| 49. |
Which of the below is an incorrect annotation with respect to JUnits? |
| A. | @Test |
| B. | @BeforeClass |
| C. | @Junit |
| D. | @AfterEach |
| Answer» D. @AfterEach | |
| 50. |
Which of the below statement about JUnit is false? |
| A. | It is an open source framework |
| B. | It provides annotation to identify test methods |
| C. | It provides test runners for running test |
| D. | They cannot be run automatically |
| Answer» E. | |