OCA Java SE 8 Mock Exam 2 - OCA Mock Question 19


Consider the following code sequence:

Which of the following statements will compile without syntax or runtime errors if they replace the comment line?

        public class Main{ 
            public int i; 
            public static void main(String argv[]){ 
                Main sc = new Main(); 
                // Comment line 
  1. sc.i = 5;
  2. int j = sc.i;
  3. sc.i = 5.0;
  4. System.out.println(sc.i);


a, b, and d


Option c is incorrect because you cannot assign a double value to an integer variable.