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...

When describing a document’s measurements, which dimension is listed first: the width or the height?

What will be an ideal response?

Computer Science & Information Technology

Which of the following is not a metric used in dynamic routing protocols?

a. Hop count b. Cost c. Runs d. Ticks

Computer Science & Information Technology

A closed operating system allows no modifications

Indicate whether the statement is true or false

Computer Science & Information Technology

If your network consists of only two, three, or four routers, RIP's easy configuration often makes it worth putting up with slower convergence.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology