nerdexam
Oracle

1Z0-809 · Question #176

Given: public class Test { public static final int MIN = 1; public static void main(String[] args) { int x = 0; //line n1 if (checkLimit(x)) { System.out.println("Java SE"); } else {…

The correct answer is B. Java EE. There is no NullPointerException thrown,the value of x is zero, so checkLimit (x) should return "false".

Java Class Design

Question

Given: public class Test { public static final int MIN = 1; public static void main(String[] args) { int x = 0; //line n1 if (checkLimit(x)) { System.out.println("Java SE"); } else { System.out.println("Java EE"); } } public static boolean checkLimit(int x) { return (x >= MIN) ? true : false; } } And given the commands: javac Test java Test What is the result?

Options

  • AA NullPointerException is thrown at runtime.
  • BJava EE
  • CJava EE
  • DCompilation fails at line n1.

How the community answered

(31 responses)
  • A
    19% (6)
  • B
    71% (22)
  • C
    3% (1)
  • D
    6% (2)

Explanation

There is no NullPointerException thrown,the value of x is zero, so checkLimit (x) should return "false".

Topics

#static methods#ternary operator#static fields#conditional logic

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice