Java OCA OCP Practice Question 825

Question

What does the following do?

public class Main { 
   interface Printable { 
      boolean print(double angle); 
   } //from  w  w w. ja  va2s.  com
   static void prepare(double angle, Printable t) { 
      boolean ready = t.print(angle);  // k1 
      System.out.println(ready); 
   } 
   public static void main(String[] args) { 
      prepare(45, d => d > 5 || d < -5);   // k2 
   } 
} 
  • A. It prints true.
  • B. It prints false.
  • C. It doesn't compile due to line k1.
  • D. It doesn't compile due to line k2.
  • E. It doesn't compile due to another line.


D.

Note

The lambda syntax is incorrect.

It should be ->, not =>.

Option D is correct.

If this was fixed, Option A would be correct.




PreviousNext

Related