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








Question

Which of these compile when replacing line 2? (Choose all that apply)

     1: char[]c = new char[2]; 
     2: // INSERT CODE HERE 
  1. int length = c.length;
  2. int length = c.length();
  3. int length = c.size;
  4. int length = c.size();
  5. int length = c.capacity;
  6. int length = c.capacity();
  7. None of the above.




Answer



A.

Note

Arrays define a property called length.

length is not a method, so parentheses are not allowed.