Java OCA OCP Practice Question 280

Question

Fill in the blank to make the code compile:

package animal; 
public class Cat { 
       public String name; 
       public static void main(String[] meow) { 
         Cat cat = new Cat(); 
         ____  = "MM"; 
       } 
} 
A.   cat.name 
B.   cat-name 
C.   cat.setName 
D.   cat[name] 


A.

Note

Java uses dot notation to reference instance variables in a class, making Option A correct.




PreviousNext

Related