InterviewSolution
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.
| 1. |
What Is Multi-resolution Image Api In Java 9? |
|
Answer» With Java 9, a new multi-resolution image API has been introduced which supports multiple images with different resolution variants. This API ALLOWS a SET of images with different resolution to be used as a single multi-resolution image. FOLLOWING are major operations of multi-resolution image:-
With Java 9, a new multi-resolution image API has been introduced which supports multiple images with different resolution variants. This API allows a set of images with different resolution to be used as a single multi-resolution image. Following are major operations of multi-resolution image:- |
|
| 2. |
Explain Purpose Of Completablefuture? |
|
Answer» CompletableFuture CLASS was introduced in Java 8 to represent the Future which can be completed by setting its value and status explicitly. It can be used as java.util.concurrent.CompletionStage. It supports DEPENDENT functions and actions which got triggered upon the future's COMPLETION. In java 9 CompletableFuture API has been enhanced further. Following are the relevant changes done to the API.
CompletableFuture class was introduced in Java 8 to represent the Future which can be completed by setting its value and status explicitly. It can be used as java.util.concurrent.CompletionStage. It supports dependent functions and actions which got triggered upon the future's completion. In java 9 CompletableFuture API has been enhanced further. Following are the relevant changes done to the API. |
|
| 3. |
What Are The Changes Made To Diamond Operator In Java 9? |
|
Answer» In java 9, it can be USED with ANONYMOUS class as well to simplify code and IMPROVES READABILITY. In java 9, it can be used with anonymous class as well to simplify code and improves readability. |
|
| 4. |
What Changes Are Made To Optional Class In Java 9? |
|
Answer» Optional Class was INTRODUCED in Java 8 to avoid NULL checks and NullPointerException issues. In java 9, three new methods are ADDED to improve its functionality.
Optional Class was introduced in Java 8 to avoid null checks and NullPointerException issues. In java 9, three new methods are added to improve its functionality. |
|
| 5. |
What Are The Changes Made To @deprecated Annotation In Java 9? |
|
Answer» With Java 9, two new enhancements are made to @Deprecated annotation:-
With Java 9, two new enhancements are made to @Deprecated annotation:- |
|
| 6. |
Explain The Use Of Ofnullable Method In Stream? |
|
Answer» ofNullable method is introduced to prevent NullPointerExceptions and to avoid null checks for streams. This method RETURNS a SEQUENTIAL STREAM containing SINGLE element, if non-null, otherwise returns an EMPTY Stream. ofNullable method is introduced to prevent NullPointerExceptions and to avoid null checks for streams. This method returns a sequential Stream containing single element, if non-null, otherwise returns an empty Stream. |
|
| 7. |
Explain The Purpose Of Try-with-resource Statement? |
|
Answer» The try-with-resources statement is a try statement with one or more resources duly declared. Here resource is an OBJECT which should be closed once it is no more REQUIRED. The try-with-resources statement ensures that each resource is closed after the requirement FINISHES. Any object implementing java.lang.AutoCloseable or java.io.Closeable, interface can be USED as a resource. The try-with-resources statement is a try statement with one or more resources duly declared. Here resource is an object which should be closed once it is no more required. The try-with-resources statement ensures that each resource is closed after the requirement finishes. Any object implementing java.lang.AutoCloseable or java.io.Closeable, interface can be used as a resource. |
|
| 8. |
Explain The Use Of Takewhile Method In Stream? |
|
Answer» takeWhile METHOD takes all the values until the predicate returns false. It returns, in CASE of ordered stream, a stream CONSISTING of the longest PREFIX of ELEMENTS taken from this stream matching the given predicate. takeWhile method takes all the values until the predicate returns false. It returns, in case of ordered stream, a stream consisting of the longest prefix of elements taken from this stream matching the given predicate. |
|
| 9. |
What Are The Changes In Iterate Method Of Stream? |
|
Answer» ITERATE method now has HASNEXT predicate as parameter which STOPS the LOOP once hasNext predicate returns FALSE. iterate method now has hasNext predicate as parameter which stops the loop once hasNext predicate returns false. |
|
| 10. |
What Are The Changes Made To Stream From Java 8 In Java 9? |
|
Answer» Streams were INTRODUCED in JAVA to help DEVELOPERS perform aggregate OPERATIONS from a SEQUENCE of objects. With Java 9, few more methods are added to make streams better.
Streams were introduced in Java to help developers perform aggregate operations from a sequence of objects. With Java 9, few more methods are added to make streams better. |
|
| 11. |
Can You Perform Some Function If A Process Exits? |
|
Answer» ProcessHandle class provides method to CHECK PROCESSES' liveness and to destroy processes. It has onExit method, the COMPLETABLEFUTURE class can PERFORM action asynchronously when process exits. ProcessHandle class provides method to check processes' liveness and to destroy processes. It has onExit method, the CompletableFuture class can perform action asynchronously when process exits. |
|
| 12. |
Explain The Use Of Dropwhile Method In Stream? |
|
Answer» dropWhile method throw away all the VALUES at the start until the predicate RETURNS true. It returns, in CASE of ordered stream, a stream consisting of the remaining elements of this stream after DROPPING the longest prefix of elements matching the given predicate. dropWhile method throw away all the values at the start until the predicate returns true. It returns, in case of ordered stream, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements matching the given predicate. |
|
| 13. |
How Can You Check A System Process Details In Java 9? |
|
Answer» In Java 9 PROCESS API which is responsible to control and manage operating system processes has been improved considerably. ProcessHandle CLASS now provides processes native processes ID, start time, ACCUMULATED CPU time, arguments, command, user, parent process, and descendants. In Java 9 Process API which is responsible to control and manage operating system processes has been improved considerably. ProcessHandle Class now provides processes native processes ID, start time, accumulated CPU time, arguments, command, user, parent process, and descendants. |
|
| 14. |
What Is Default Project Structure For A Web Based Application? |
|
Answer» The following is the default project structure:-
The following is the default project structure:- |
|
| 15. |
How Many Kind Of Variables/methods An Interface Supports In Java 9? |
|
Answer» With Java 9 interfaces can have following type of variables/METHODS:
With Java 9 interfaces can have following type of variables/methods: |
|
| 16. |
How Can You Run A Multi Release Jar On Different Version Of Java? Give An Example? |
|
Answer» Syntax is same on both java versions, result will be DIFFERENT. Run with JDK 7. C:JAVA > java -CP test.jar com.tutorialspoint.Tester Inside Java 7 Run with JDK 9. C:JAVA > java -cp test.jar com.tutorialspoint.Tester Inside Java 9 Syntax is same on both java versions, result will be different. Run with JDK 7. C:JAVA > java -cp test.jar com.tutorialspoint.Tester Inside Java 7 Run with JDK 9. C:JAVA > java -cp test.jar com.tutorialspoint.Tester Inside Java 9 |
|
| 17. |
Collections Are Enhanced In Java 9. What Are The Changes And Explain? |
|
Answer» With Java 9, new factory methods are ADDED to LIST, Set and MAP interfaces to create immutable INSTANCES. These factory methods are convenience factory methods to create a collection in less verbose and in concise way. With Java 9, new factory methods are added to List, Set and Map interfaces to create immutable instances. These factory methods are convenience factory methods to create a collection in less verbose and in concise way. |
|
| 18. |
What Are The Methods Added To Collections In Java 9? |
|
Answer» With java 9, following methods are added to List, Set and MAP interfaces along with their overloaded counterparts. static <E> List<E> of(E e1, E e2, E e3); static <E> Set<E> of(E e1, E e2, E e3); static <K,V> Map<K,V> of(K k1, V V1, K K2, V v2, K k3, V v3); static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries) note:
With java 9, following methods are added to List, Set and Map interfaces along with their overloaded counterparts. static <E> List<E> of(E e1, E e2, E e3); static <E> Set<E> of(E e1, E e2, E e3); static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3); static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries) note: |
|
| 19. |
Can You Create A Multi-release Jar For Different Version Of Java? Give An Example? |
|
Answer» YES! Following command will create a multi-release jar for java 7 and java 9 VERSION. $ jar -c -F test.jar -C java7 . --release 9 -C java9 . Yes! Following command will create a multi-release jar for java 7 and java 9 version. $ jar -c -f test.jar -C java7 . --release 9 -C java9 . |
|
| 21. |
What Is Multi-release Jar Format Introduced In Java 9? |
|
Answer» In java 9, a new feature is introduced where a jar format has been enhanced to have different versions of java CLASS or resources can be MAINTAINED and USED as per the platform. In java 9, a new feature is introduced where a jar format has been enhanced to have different versions of java class or resources can be maintained and used as per the platform. |
|
| 22. |
Source Code Of A Module Lies In Which Folder? |
|
Answer» By CONVENTION, the SOURCE code of a module to LIE in same directory which is the NAME of the module. By convention, the source code of a module to lie in same directory which is the name of the module. |
|
| 23. |
How Will You Create Html5 Compliant Javadoc Using Java 9? |
|
Answer» Run the javadoc tool of JDK 9 with -html5 FLAG to GENERATE new type of DOCUMENTATION. Run the javadoc tool of jdk 9 with -html5 flag to generate new type of documentation. |
|
| 24. |
What Is Jshell In Java 9? |
|
Answer» With JShell, java has REPL capability. Using JShell, we can code and TEST java BASED LOGIC without COMPILING using javac and see the result of CALCULATIONS directly. With JShell, java has REPL capability. Using JShell, we can code and test java based logic without compiling using javac and see the result of calculations directly. |
|
| 25. |
What Is Module In Java 9? |
|
Answer» In Java 9, a new kind of PROGRAMMING component called MODULE has been introduced. A module is a self-describing collection of code and data and has a name to IDENTIFY it. In Java 9, a new kind of programming component called module has been introduced. A module is a self-describing collection of code and data and has a name to identify it. |
|
| 26. |
What Are The Significant Changes In Java 9? |
|
Answer» There are 90+ enhancements added to Java 8, the most significant ones are mentioned below :-
There are 90+ enhancements added to Java 8, the most significant ones are mentioned below :- |
|
| 27. |
What Features Module System Has Provided? |
|
Answer» With the Modules component, following ENHANCEMENTS has been added in Java 9 :-
With the Modules component, following enhancements has been added in Java 9 :- |
|