

MCQOPTIONS
Saved Bookmarks
This section includes 1671 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
601. |
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 | |
602. |
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 | |
603. |
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 | |
604. |
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++) | |
605. |
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 | |
606. |
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 | |
607. |
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() | |
608. |
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. | |
609. |
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 | |
610. |
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 | |
611. |
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 | |
612. |
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 | |
613. |
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. | |
614. |
In which file database table configuration is stored? |
A. | .dbm |
B. | .hbm |
C. | .ora |
D. | .sql |
Answer» C. .ora | |
615. |
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. | |
616. |
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. | |
617. |
Which of the following is not a state of object in Hibernate? |
A. | Attached() |
B. | Detached() |
C. | Persistent() |
D. | Transient() |
Answer» B. Detached() | |
618. |
Which of the following method is used inside session only? |
A. | merge() |
B. | update() |
C. | end() |
D. | kill() |
Answer» C. end() | |
619. |
Which of the following methods hits database always? |
A. | load() |
B. | loadDatabase() |
C. | getDatabase() |
D. | get() |
Answer» E. | |
620. |
Which of the following methods returns proxy object? |
A. | loadDatabase() |
B. | getDatabase() |
C. | load() |
D. | get() |
Answer» D. get() | |
621. |
SessionFactory is a thread-safe object. |
A. | True |
B. | False |
Answer» B. False | |
622. |
Which of the following is not a core interface of Hibernate? |
A. | Configuration |
B. | Criteria |
C. | SessionManagement |
D. | Session |
Answer» D. Session | |
623. |
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 | |
624. |
Which jar provides FileUtils which contains methods for file operations? |
A. | file |
B. | apache commons |
C. | file commons |
D. | dir |
Answer» C. file commons | |
625. |
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) | |
626. |
How can we create a symbolic link to file? |
A. | createLink() |
B. | createSymLink() |
C. | createSymbolicLink() |
D. | createTempLink() |
Answer» D. createTempLink() | |
627. |
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() | |
628. |
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) | |
629. |
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) | |
630. |
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() | |
631. |
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. | |
632. |
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) | |
633. |
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 | |
634. |
What is the substitute of Rhino javascript engine in java 8? |
A. | Nashorn |
B. | V8 |
C. | Inscript |
D. | Narcissus |
Answer» B. V8 | |
635. |
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 | |
636. |
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 | |
637. |
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 | |
638. |
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 | |
639. |
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() | |
640. |
What is the return type of lambda expression? |
A. | String |
B. | Object |
C. | void |
D. | function |
Answer» E. | |
641. |
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 | |
642. |
Which of the following is not introduced with Java 8? |
A. | Stream API |
B. | Serialization |
C. | Spliterator |
D. | Lambda Expression |
Answer» C. Spliterator | |
643. |
What is used to inject mock fields into the tested object automatically? |
A. | @InjectMocks |
B. | @Inject |
C. | @InjectMockObject |
D. | @Mock |
Answer» B. @Inject | |
644. |
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(..); | |
645. |
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. | |
646. |
What does assertSame() method use for assertion? |
A. | equals() method |
B. | isEqual() method |
C. | == |
D. | compare() method |
Answer» D. compare() method | |
647. |
Which method is used to verify the actual and expected results in Junits? |
A. | assert() |
B. | equals() |
C. | == |
D. | isEqual() |
Answer» B. equals() | |
648. |
Which of these is not a mocking framework? |
A. | EasyMock |
B. | Mockito |
C. | PowerMock |
D. | MockJava |
Answer» E. | |
649. |
Which of the below is an incorrect annotation with respect to JUnits? |
A. | @Test |
B. | @BeforeClass |
C. | @Junit |
D. | @AfterEach |
Answer» D. @AfterEach | |
650. |
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. | |