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. |
How Will You Create A Base64 Encoder That Encodes Using The Url And Filename Safe Type Base64 Encoding Scheme? |
|
Answer» getUrlEncoder() METHOD of Base64 class RETURNS a Base64.Encoder that encodes USING the URL and Filename safe TYPE base64 encoding SCHEME. getUrlEncoder() method of Base64 class returns a Base64.Encoder that encodes using the URL and Filename safe type base64 encoding scheme. |
|
| 2. |
How Will You Create A Base64 Decoder That Decodes Using The Url And Filename Safe Type Base64 Encoding Scheme? |
|
Answer» getUrlDecoder() method of BASE64 CLASS RETURNS a Base64.Decoder that DECODES using the URL and Filename safe type base64 encoding scheme. getUrlDecoder() method of Base64 class returns a Base64.Decoder that decodes using the URL and Filename safe type base64 encoding scheme. |
|
| 3. |
How Will You Create A Base64 Encoder That Encodes Using The Mime Type Base64 Encoding Scheme? |
|
Answer» getMimeEncoder() METHOD of BASE64 class returns a Base64.Encoder that encodes USING the MIME TYPE base64 encoding scheme. getMimeEncoder() method of Base64 class returns a Base64.Encoder that encodes using the MIME type base64 encoding scheme. |
|
| 4. |
How Will You Create A Base64 Decoder That Decodes Using The Mime Type Base64 Encoding Scheme? |
|
Answer» getMimeDecoder() METHOD of BASE64 CLASS returns a Base64.Decoder that DECODES USING the MIME type base64 decoding scheme. getMimeDecoder() method of Base64 class returns a Base64.Decoder that decodes using the MIME type base64 decoding scheme. |
|
| 5. |
How Will You Create A Base64 Encoder? |
|
Answer» getEncoder() METHOD of Base64 class returns a Base64.Encoder that encodes USING the Basic TYPE base64 encoding scheme. getEncoder() method of Base64 class returns a Base64.Encoder that encodes using the Basic type base64 encoding scheme. |
|
| 6. |
How Will You Create A Base64 Decoder? |
|
Answer» getDecoder() method of BASE64 class returns a Base64.Decoder that decodes using the Basic type base64 ENCODING SCHEME. getDecoder() method of Base64 class returns a Base64.Decoder that decodes using the Basic type base64 encoding scheme. |
|
| 7. |
Which Class Implements An Encoder For Encoding Byte Data Using The Base64 Encoding Scheme In Java8? |
|
Answer» STATIC CLASS Base64.Encoder − This class IMPLEMENTS an encoder for encoding byte data using the Base64 encoding scheme as SPECIFIED in RFC 4648 and RFC 2045. static class Base64.Encoder − This class implements an encoder for encoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. |
|
| 8. |
Which Class Implements A Decoder For Decoding Byte Data Using The Base64 Encoding Scheme In Java8? |
|
Answer» STATIC class Base64.Decoder − This class IMPLEMENTS a decoder for DECODING byte data USING the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. static class Base64.Decoder − This class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. |
|
| 9. |
How Will You Get The Instant Of Zoned Date Time Using Time In Of Milliseconds Using Java8? |
|
Answer» Following CODE gets the INSTANT of ZONED date time using time in of MILLISECONDS − Instant now = currentDate.toInstant(); Following code gets the instant of zoned date time using time in of milliseconds − Instant now = currentDate.toInstant(); |
|
| 10. |
How Will You Get The Instant Of Local Date Time Using Time In Of Milliseconds Using Java8? |
|
Answer» Following code gets the INSTANT of local DATE time USING time in of MILLISECONDS − Instant now = currentDate.toInstant(); Following code gets the instant of local date time using time in of milliseconds − Instant now = currentDate.toInstant(); |
|
| 11. |
How Will You Get The Instant Of Current Date In Terms Of Milliseconds Using Java8? |
|
Answer» FOLLOWING code gets the INSTANT of current DATE in terms of MILLISECONDS − //GET the instant of current date in terms of milliseconds Instant now = currentDate.toInstant(); Following code gets the instant of current date in terms of milliseconds − //Get the instant of current date in terms of milliseconds Instant now = currentDate.toInstant(); |
|
| 12. |
How Will You Get Second Saturday Of Next Month Using Java8? |
|
Answer» Following CODE gets second SATURDAY of next month USING java8 − //get the second saturday of next month LocalDate firstInYear = LocalDate.of(date1.getYear(),date1.getMonth(), 1); LocalDate secondSaturday = firstInYear.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)).with(TemporalAdjusters.next(DayOfWeek.SATURDAY)); System.out.println("Second Saturday on : " + secondSaturday); Following code gets second saturday of next month using java8 − //get the second saturday of next month LocalDate firstInYear = LocalDate.of(date1.getYear(),date1.getMonth(), 1); LocalDate secondSaturday = firstInYear.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)).with(TemporalAdjusters.next(DayOfWeek.SATURDAY)); System.out.println("Second Saturday on : " + secondSaturday); |
|
| 13. |
How Will You Get Next Tuesday Using Java8? |
|
Answer» FOLLOWING CODE gets NEXT tuesday using JAVA8 − //get the next tuesday Following code gets next tuesday using java8 − //get the next tuesday |
|
| 14. |
How Will You Add 10 Years To Current Date Using Local Datetime Api Of Java8? |
|
Answer» Following CODE adds 10 years to current date USING local datetime api − //ADD 10 years to the current date Following code adds 10 years to current date using local datetime api − //add 10 years to the current date |
|
| 15. |
How Will You Add 1 Year To Current Date Using Local Datetime Api Of Java8? |
|
Answer» Following code ADDS 1 year to current date USING local datetime api − //ADD 1 year to the current date Following code adds 1 year to current date using local datetime api − //add 1 year to the current date |
|
| 16. |
How Will You Add 1 Month To Current Date Using Local Datetime Api Of Java8? |
|
Answer» FOLLOWING code ADDS 1 month to current date USING local datetime api: //add 1 month to the current date Following code adds 1 month to current date using local datetime api: //add 1 month to the current date |
|
| 17. |
How Will You Add 1 Week To Current Date Using Local Datetime Api Of Java8? |
|
Answer» Following CODE ADDS 1 week to current DATE USING local datetime api − //ADD 1 week to the current date Following code adds 1 week to current date using local datetime api − //add 1 week to the current date |
|
| 18. |
How Will You Get The Current Date Using Local Datetime Api Of Java8? |
|
Answer» Following CODE GETS the current date USING local datetime API − //Get the current date Following code gets the current date using local datetime api − //Get the current date |
|
| 19. |
What Is Chromounits In Java8? |
|
Answer» JAVA.time.temporal.ChronoUnit enum is added in Java 8 to replace the INTEGER VALUES USED in old API to represent DAY, month, etc. java.time.temporal.ChronoUnit enum is added in Java 8 to replace the integer values used in old API to represent day, month, etc. |
|
| 20. |
What Is Zoned Datetime Api In Java8? |
|
Answer» ZONED − SPECIALIZED date-time API to DEAL with VARIOUS timezones. Zoned − Specialized date-time API to deal with various timezones. |
|
| 21. |
What Is Local Datetime Api In Java8? |
|
Answer» LOCAL − SIMPLIFIED date-time API with no COMPLEXITY of TIMEZONE handling. Local − Simplified date-time API with no complexity of timezone handling. |
|
| 22. |
Can You Execute Javascript Code From Java 8 Code Base? |
|
Answer» YES! Using ScriptEngineManager, JAVASCRIPT CODE can be CALLED and interpreted in Java. Yes! Using ScriptEngineManager, JavaScript code can be called and interpreted in Java. |
|
| 23. |
What Is Jjs In Java8? |
|
Answer» For NASHORN engine, JAVA 8 introduces a new command line TOOL, jjs, to execute JAVASCRIPT CODES at console. For Nashorn engine, JAVA 8 introduces a new command line tool, jjs, to execute javascript codes at console. |
|
| 24. |
What Is Nashorn In Java8? |
|
Answer» With Java 8, Nashorn, a much IMPROVED javascript engine is INTRODUCED, to replace the existing Rhino. Nashorn provides 2 to 10 TIMES better performance, as it directly compiles the code in memory and passes the bytecode to JVM. Nashorn uses invokedynamics feature, introduced in Java 7 to improve performance. With Java 8, Nashorn, a much improved javascript engine is introduced, to replace the existing Rhino. Nashorn provides 2 to 10 times better performance, as it directly compiles the code in memory and passes the bytecode to JVM. Nashorn uses invokedynamics feature, introduced in Java 7 to improve performance. |
|
| 25. |
What Is Optional In Java8? |
|
Answer» Optional is a container OBJECT which is used to contain not-null objects. 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. It is INTRODUCED in JAVA 8 and is similar to what Optional is in Guava. Optional is a container object which is used to contain not-null objects. 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. It is introduced in Java 8 and is similar to what Optional is in Guava. |
|
| 26. |
How Will You Get The Average Of All Numbers Present In A List Using Java 8? |
|
Answer» Following CODE will PRINT the average of all numbers present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); Following code will print the average of all numbers present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); |
|
| 27. |
How Will You Get The Sum Of All Numbers Present In A List Using Java 8? |
|
Answer» Following CODE will print the SUM of all numbers present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); Following code will print the sum of all numbers present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); |
|
| 28. |
How Will You Get The Lowest Number Present In A List Using Java 8? |
|
Answer» Following code will PRINT the highest NUMBER present in a list. List NUMBERS = Arrays.asList(3, 2, 2, 3, 7, 3, 5); Following code will print the highest number present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); |
|
| 29. |
How Will You Get The Highest Number Present In A List Using Java 8? |
|
Answer» Following code will print the highest number PRESENT in a LIST. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); Following code will print the highest number present in a list. List numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); |
|
| 30. |
What Are Statistics Collectors In Java 8? |
|
Answer» With Java 8, STATISTICS COLLECTORS are introduced to calculate all statistics when STREAM PROCESSING is being done. With Java 8, statistics collectors are introduced to calculate all statistics when stream processing is being done. |
|
| 31. |
What Are Collectors In Java 8? |
|
Answer» COLLECTORS are used to COMBINE the result of processing on the elements of a stream. Collectors can be used to return a list or a string. List<String>strings = Arrays.asList("ABC", "", "bc", "efg", "ABCD","", "JKL"); Collectors are used to combine the result of processing on the elements of a stream. Collectors can be used to return a list or a string. List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); |
|
| 32. |
What Is Parallel Processing In Java 8? |
|
Answer» parallelStream is the alternative of STREAM for parallel processing. Take a look at the FOLLOWING CODE SEGMENT that prints a count of empty strings using parallelStream. List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); parallelStream is the alternative of stream for parallel processing. Take a look at the following code segment that prints a count of empty strings using parallelStream. List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); |
|
| 33. |
How Will You Print 10 Random Numbers In A Sorted Order In Java 8? |
|
Answer» The following code segment SHOWS how to PRINT 10 random numbers in a SORTED order. Random random = NEW Random(); The following code segment shows how to print 10 random numbers in a sorted order. Random random = new Random(); |
|
| 34. |
What Is The Purpose Of Sorted Method Of Stream In Java 8? |
|
Answer» The 'sorted' METHOD is USED to SORT the STREAM. The 'sorted' method is used to sort the stream. |
|
| 35. |
How Will You Print 10 Random Numbers In Java 8? |
|
Answer» The FOLLOWING code segment shows how to print 10 RANDOM NUMBERS. Random random = new Random(); The following code segment shows how to print 10 random numbers. Random random = new Random(); |
|
| 36. |
What Is The Purpose Of Limit Method Of Stream In Java 8? |
|
Answer» The 'limit' METHOD is USED to REDUCE the SIZE of the STREAM. The 'limit' method is used to reduce the size of the stream. |
|
| 37. |
How Will You Print Count Of Empty Strings In Java 8? |
|
Answer» The following CODE segment prints a count of empty STRINGS using filter. LIST<STRING>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); The following code segment prints a count of empty strings using filter. List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); |
|
| 38. |
What Is The Purpose Of Filter Method Of Stream In Java 8? |
|
Answer» The 'filter' method is USED to ELIMINATE elements BASED on a criteria. The 'filter' method is used to eliminate elements based on a criteria. |
|
| 39. |
How Will You Print Unique Squares Of Numbers In Java 8? |
|
Answer» The following code segment prints UNIQUE SQUARES of numbers using map. List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); //get list of unique squares List<Integer> squaresList = numbers.stream().map( i -> i*i).DISTINCT().collect(Collectors.toList()); The following code segment prints unique squares of numbers using map. List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); //get list of unique squares List<Integer> squaresList = numbers.stream().map( i -> i*i).distinct().collect(Collectors.toList()); |
|
| 40. |
What Is The Purpose Of Map Method Of Stream In Java 8? |
|
Answer» The 'MAP' METHOD is used to map each element to its corresponding RESULT. The 'map' method is used to map each element to its corresponding result. |
|
| 41. |
How Will You Print 10 Random Numbers Using Foreach Of Java 8? |
|
Answer» The following code SEGMENT shows how to print 10 RANDOM numbers using FOREACH. Random random = new Random(); The following code segment shows how to print 10 random numbers using forEach. Random random = new Random(); |
|
| 42. |
What Is The Purpose Of Foreach Method Of Stream In Java 8? |
|
Answer» STREAM has provided a NEW method 'forEach' to ITERATE each ELEMENT of the stream. Stream has provided a new method 'forEach' to iterate each element of the stream. |
|
| 43. |
What Is The Difference Between Collections And Stream In Java8 ? |
|
Answer» STREAM operations do the iterations internally over the source ELEMENTS provided, in contrast to COLLECTIONS where explicit ITERATION is required. Stream operations do the iterations internally over the source elements provided, in contrast to Collections where explicit iteration is required. |
|
| 44. |
What Is Stream Pipelining In Java 8? |
|
Answer» Most of the stream operations return stream itself so that their result can be pipelined. These operations are called intermediate operations and their FUNCTION is to take input, process them, and return output to the target. collect() method is a terminal OPERATION which is normally present at the end of the PIPELINING operation to mark the end of the stream. Most of the stream operations return stream itself so that their result can be pipelined. These operations are called intermediate operations and their function is to take input, process them, and return output to the target. collect() method is a terminal operation which is normally present at the end of the pipelining operation to mark the end of the stream. |
|
| 45. |
What Is Streams In Java 8? |
|
Answer» Stream represents a SEQUENCE of OBJECTS from a source, which SUPPORTS aggregate OPERATIONS. Stream represents a sequence of objects from a source, which supports aggregate operations. |
|
| 46. |
How Will You Call A Static Method Of An Interface In A Class? |
|
Answer»
interface Vehicle { Using name of the interface. interface Vehicle { |
|
| 47. |
How Will You Call A Default Method Of An Interface In A Class? |
|
Answer» Using super keyword ALONG with INTERFACE NAME. interface VEHICLE { Using super keyword along with interface name. interface Vehicle { |
|
| 48. |
What Are Static Default Methods? |
|
Answer» An interface can also have static HELPER methods from JAVA 8 onwards. PUBLIC interface vehicle { An interface can also have static helper methods from Java 8 onwards. public interface vehicle { |
|
| 49. |
What Are Default Methods? |
|
Answer» With java 8, an INTERFACE can have default IMPLEMENTATION of a FUNCTION in INTERFACES. With java 8, an interface can have default implementation of a function in interfaces. |
|
| 50. |
What Is The Purpose Of Unaryoperator<t> Functional Interface? |
|
Answer» It represents an operation on a SINGLE operand that PRODUCES a RESULT of the same TYPE as its operand. It represents an operation on a single operand that produces a result of the same type as its operand. |
|