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








Question

Which of the following will return the position of the first letter a where the string s contains "banana"?

  1. lastIndexOf(2,s);
  2. s.indexOf('a');
  3. s.charAt(2);
  4. indexOf(s,'v');




Answer



b

Note

The lastIndexOf method takes a single argument of char.

The charAt method returns the letter at the position.