Java OCA OCP Practice Question 52

Question

What's wrong with the following code?


public class Main {
   public static void main(String args[]) {
      Boolean b = new Boolean("TRUE");
      if (b) {/*from  ww w  . j  a v a  2  s.com*/
         for (Integer i = 0; i < 10; ++i) {
            System.out.println(i);
         }
      }
   }
}
  • A. There is nothing wrong with the code. It compiles and runs fine.
  • B. The if condition should be a boolean instead of a Boolean.
  • C. The index of the for statement should be an int instead of an Integer.
  • D. It is illegal to construct a Boolean value.


A



PreviousNext

Related