To check if a string s contains the prefix "Java", you may write

a. if (s.startsWith("Java")) ...
b. if (s.indexOf("Java") == 0) ...
c. if (s.substring(0, 4).equals("Java")) ...
d. if (s.charAt(0) == 'J' && s.charAt(1) == 'a' && s.charAt(2) == 'v' && s.charAt(3) == 'a') ...

abcd They are all correct.

Computer Science & Information Technology

You might also like to view...

In a new document in OpenOffice Writer, the space between the text and the left, right, top, and bottom of the paper are called ________

A) line breaks B) margins C) tab stops D) sections

Computer Science & Information Technology

Excel normally uses all the selected data in creating a chart

Indicate whether the statement is true or false

Computer Science & Information Technology