Monday, 21 December 2015

Java 8 - MCQ set 1 (25 questions, 55 marks)

Java 8 - MCQ set 1 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks 

  1. Lambdas introduced in Java 8 allow us to treat -

  2. a.Data as code
    b.Code as data
    c.none
    d.all

  3. The newly introduced Streams API is available in which package:

  4. a.java.io.streams
    b.java.io.stream
    c.java.util.streams
    d.java.util.stream

  5. Which class can be used Instead of System.getCurrentTimeMillis() to get a date and time -

  6. a.Clock
    b.Date
    c.Time
    d.Timer

  7. Lambda expressions are based on

  8. a.Procedural programming
    b.Functional programming
    c.Data programming
    d.All

  9. how many methods are there in the functional interface?

  10. a.0
    b.1
    c.2
    d.3



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. In Java 8 Interfaces, methods can be:

  12. a.default
    b.abstract
    c.all
    d.none

  13. The Java 8 API with a sequence of elements which of these supports sequential and parallel aggregate operations -

  14. a.Hadoop
    b.Streams
    c.sequence programming
    d.Big-data

  15. Stream operations can be divided into

  16. a.Terminal types
    b.Intermediate types
    c.All
    d.None

  17. Which package contains Date/Time (JSR 310) API -

  18. a.java.time
    b.java.util.time
    c.java.timedate
    d.java.util.calendar

  19. Nashorn the new JavaScript engine is an implementation of -

  20. a.javax.engine.Engine
    b.javax.script.Engine
    c.javax.javaScript.Engine
    d.javax.script.ScriptEngine

  21. Which is new command line tool for the Nashhorn JavaScript engine -

  22. a.jcs
    b.jfs
    c.jjs
    d.jss

  23. Which of these should be used to show package-level and class-level dependencies of Class files

  24. a.dep
    b.ideps
    c.jdep
    d.jdeps

  25. Predicate is in which package

  26. a.java.util.predicate
    b.java.util.object
    c.java.util.objects
    d.java.util.predict

  27. Which of these represents a process that accepts one argument and produces a result

  28. a.Function
    b.Process
    c.Method
    d.JavaFunctions

  29. Function is ?

  30. a.Class
    b.Interface
    c.Lambda Expression
    d.Object



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. PermGen space has been replaced with which of these in Java 8 -

  32. a.PermSpace
    b.PermSpaceGen
    c.Metaspace
    d.MetaGenSpace

  33. What can help us in avoiding NullPointeExceptions and null checks in Java 8 -

  34. a.Optional
    b.Required
    c.NotNull
    d.NotRequired

  35. code for Java 8 essentially used to be -

  36. a.Declarative
    b.Imperative
    c.Subjective
    d.None

  37. R apply(T t) is a method of-

  38. a.Function
    b.Process
    c.Predicate
    d.None

  39. What is Predicate in Java 8 -

  40. a.method
    b.class
    c.Interface
    d.Framework

  41. How sorting speed has been improved significantly on multi-core machines by using -

  42. a.Arrays.parallelSort
    b.Arrays.sort
    c.Collection.parallelSort
    d.Arrays.sortParallelly

  43. Which is aggregate operation in Java 8

  44. a.filter
    b.map
    c.forEach
    d.All

  45. Example of functional interfaces -

  46. a.java.util.concurrent.Callable
    b.java.lang.Runnable
    c.All
    d.None

  47. Which method can be used to check null on an Optional variable

  48. a.isPresent()
    b.isNullable()
    c.isPresentable()
    d.isNotNull()

  49. We need to override which Predicate method -

  50. a.predict(T t)
    b.predictable(T t)
    c.testable(T t)
    d.test(T t)




Quiz 1 - Correct answers



EASY
1) b
2) d
3) a
4) b
5) b

MEDIUM
6) c
7) b
8) c
9) a
10) d
11) c
12) d
13) b
14) a
15) b

HARD
16) c
17) a
18) b
19) a
20) c
21) a
22) d
23) c
24) a
25) d






Java 8 - MCQ set 2 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks 

  1. Functional interfaces can be annotated as

  2. a.@Function
    b.@FunctionalInterface
    c.@Functional
    d.@Interface

  3. Functional interfaces method is

  4. a.static
    b.abstract
    c.final
    d.none

  5. What needs to be implemented to use lambda expression

  6. a.Functional interface
    b.Functional class
    c.Functional method
    d.Functional object

  7. Functional interface methods can be declared as

  8. a.static
    b.abstract
    c.final
    d.All

  9. What will be output of following code -


  10. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. void accept(T t) is method of -

  12. a.Consumer
    b.Producer
    c.Both
    d.None

  13. Which of these does Stream filter() operates on

  14. a.Predicate
    b.Interface
    c.Class
    d.Methods

  15. Which of these does Stream map() operates on

  16. a.Class
    b.Interface
    c.Predicate
    d.Function

  17. Which of these does forEach() operates on

  18. a.Methods
    b.Consumer
    c.Producer
    d.Predicate

  19. A pipeline is a sequence of what operations in java 8

  20. a.multi-threading
    b.concurrent
    c.consequent
    d.stream

  21. How can we obtain source of objects in java 8?

  22. a.Stream stream()
    b.Stream obtain()
    c.Stream obtainSource()
    d.All

  23. What will be output of following code -


  24. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  25. What will be output of following code -


  26. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  27. What will be output of following code -


  28. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  29. What will be output of following code -


  30. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What will be output of following code -


  32. a.Strings
    b.Integers
    c.Characters
    d.Float

  33. Lambda expressions are __________ scoped

  34. a.Lexically
    b.Semantically
    c.Binary
    d.None

  35. On which of these does annotations can be used on in Java 8

  36. a.Local variables
    b.Super classes
    c.Generic types
    d.All of these

  37. What will be output of following code -


  38. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  39. What will be output of following code -


  40. a.compilation error
    b.compilation error
    c.Compile and execute without any Exception or error
    d.None

  41. What will be output of following code -


  42. a.output may be 125
    b.output may be 695
    c.output may be 1511
    d.output may be 456

  43. What will be output of following code -


  44. a.Full Name: [none]
    b.
    c.compilation error
    d.compilation error

  45. What will be output of the following code -


  46. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  47. What will be output of following code -


  48. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None

  49. What will be output of the following code -


  50. a.compilation error
    b.Runtime Exception
    c.Compile and execute without any Exception or error
    d.None




Quiz 2 - Correct answers



EASY
1) b
2) b
3) a
4) d
5) c

MEDIUM
6) a
7) a
8) d
9) b
10) d
11) a
12) c
13) b
14) c
15) c

HARD
16) b
17) a
18) d
19) c
20) c
21) b
22) a
23) c
24) c
25) a

4 comments:

  1. Thank for the solution , you can see more here Interview Questions

    ReplyDelete
  2. Very nice information. Thanks For sharing good article.I have written java8 blog visit Java8 Tutorials

    ReplyDelete
  3. Thanks for shared wonderful information of giving best information.its more useful and more helpful. great doing keep sharing: Visit: https://nearlearn.com/machine-learning-classroom-training-in-bangalore-india

    Best Machine Learning Course in Bangalore

    ReplyDelete