Java Basic


  1. What are the two types of Streams offered by java 8?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Sequential stream and parallel stream are two types of stream provided by java.


  1. What is Optional object used for?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    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.



  1. What does Files.lines(Path path) do?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Files.lines(Path path) that reads all lines from a file as a Stream.


  1. Which feature of java 8 enables us to create a work stealing thread pool using all available processors at its target?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Executors newWorkStealingPool() method to create a work-stealing thread pool using all available processors as its target parallelism level.



  1. What is the substitute of Rhino javascript engine in Java 8?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    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.