Java OCA OCP Practice Question 434

Question

Which line(s) of code in the following program will cause a compilation error?

public class Main{ 
   static int value = 0; //1 
   public static void main (String args []) //2 
    { //from   ww  w. j  a va  2 s  .  c o  m
      int 2ndArgument = Integer.parseInt (args [2]); //3 
      if ( true == 2 > 10 ) //4   
       { 
         value = -10; 
       } 
      else{ 
         value =  2ndArgument; 
       } 
      for ( ; value>0; value--) System.out.println ("A"); //5 
    } 
} 

Select 1 option

  • A. 1
  • B. 2
  • C. 3
  • D. 4
  • E. 5



    Correct Option is  : C

    Note

    2ndArgument is not a valid identifier name because an identified must not start with a digit although it can contain a digit.

    == has less precedence than > so true == 2 > 10 is same as true == (2 > 10)




    PreviousNext

    Related