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


Which of the following statements are correct 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. System.out.println(i);
  2. System.out.println(sc.i);
  3. System.out.println(Main.i);
  4. System.out.println((new Main()).i);


b and d


A is incorrect since instance variables need to be used with an object.

C is incorrect since instance variables cannot be used with a classname.