OCA Java SE 8 Core Java APIs - OCA Mock Question Core Java APIs 1-3








Question

What is output by the following code? (Choose all that apply)

     1: public class Main { 
     2:  public static void main(String[] args) { 
     3:    int my = 4; 
     4:    String v2 = "ABC"; 
     5:    String v = my + 1; 
     6:    System.out.println(v + " " + v2); 
     7:    System.out.println(my + " " + 1); 
     8:  } 
     9: } 
  1. 4 1
  2. 41
  3. 5
  4. 5 ABC
  5. 5ABC
  6. 51ABC
  7. The code does not compile.




Answer



G.

Note

Line 5 does not compile.

We cannot assign int value to string value.