Java 8(Engineering > Computer Science And Engineering ) Questions and Answers

Question 1. Which of the following does not belong: If a class inherits from some other class, it should
  1.    Make use of the parent class's capabilities
  2.    Over-ride or add the minimum to accomplish the derived class' purpose
  3.    Over-ride all the methods of its parent class
  4.    Make sure the result IS-A-KIND-OF" its base class
Explanation:-
Answer: Option C. -> Over-ride all the methods of its parent class





Question 2. How many methods are there in a functional interface in Java 8?
  1.    0
  2.    1
  3.    2
  4.    3
Explanation:-
Answer: Option B. -> 1





Question 3. PermGen space has been replaced with which of these in Java 8
  1.    PermSpace
  2.    PermSpaceGen
  3.    Metaspace
  4.    MetaGenSpace
Explanation:-
Answer: Option C. -> Metaspace





Question 4. Example of functional interfaces
  1.    java.util.concurrent.Callable
  2.    java.lang.Runnable
  3.    All
  4.    None
Explanation:-
Answer: Option C. -> All





Question 5. Using which keyword we can access a value of the instance variables and class variables of that class inside the method of that class itself.
  1.    Super
  2.    Final
  3.    This
  4.    Either super or this
Explanation:-
Answer: Option C. -> This





Question 6. Which of these does Stream map() operates on
  1.    Class
  2.    Interface
  3.    Predicate
  4.    Function
Explanation:-
Answer: Option D. -> Function





Question 7. Which is aggregate operation in Java 8
  1.    filter
  2.    map
  3.    forEach
  4.    All
Explanation:-
Answer: Option C. -> forEach





Question 8. Which of the following are not valid lambda expressions?
  1.    () -> {}
  2.    () -> Raoul"
  3.    () -> {return Mario";}
  4.    (Integer i) -> return Alan" + i;
Explanation:-
Answer: Option C. -> () -> {return Mario";}





Question 9. Functional interfaces can be annotated as
  1.    Function
  2.    FunctionalInterface
  3.    Functional
  4.    Interface
Explanation:-
Answer: Option B. -> FunctionalInterface





Question 10. Given a class named student, which of the following is a valid constructor declaration for the class?
  1.    Student (student s) { }
  2.    Student student ( ) { }
  3.    Private final student ( ) { }
  4.    Void student ( ) { }
Explanation:-
Answer: Option A. -> Student (student s) { }