Java OCA OCP Practice Question 710

Question

Which is a true statement?

  • A. If s.contains("abc") is true, then s.equals("abc") is also true.
  • B. If s.contains("abc") is true, then s.startsWith("abc") is also true.
  • C. If s.startsWith("abc") is true, then s.equals("abc") is also true.
  • D. If s.startsWith("abc") is true, then s.contains("abc") is also true.


D.

Note

Options A and B are not true if the String is deabc.

Option C is not true if the String is abcde.

Option D is true in all cases.




PreviousNext

Related