Java OCA OCP Practice Question 37

Question

Given the following application, fill in the missing values in the table starting from the top and going downward.

package competition; 
public class Robot { 
   static String weight = "A lot"; 
   /* default */ double ageMonths = 5, ageDays = 2; 

   private static boolean success = true; 

   public void main(String[] args) { 
      final String retries = "1"; 
      // P1 /*from ww  w . j a  v  a 2  s .c o  m*/
   } 
} 

Variable Type        Number of Variables Accessible at P1 
Class                :
Instance             :
Local                :
  • A. 2, 0, 1
  • B. 2, 2, 1
  • C. 1, 0, 1
  • D. 0, 2, 1


B.

Note

In this question that main() is not a static method, therefore it can access both class and instance variables. Since there are two class variables and two instance variables defined, Option B is the correct answer.




PreviousNext

Related