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

```
a. if (s.endsWith("Java")) ...
b. if (s.lastIndexOf("Java") >= 0) ...
c. if (s.substring(s.length() - 4).equals("Java")) ...
d. if (s.substring(s.length() - 5).equals("Java")) ...
e. if (s.charAt(s.length() - 4) == 'J' && s.charAt(s.length() - 3) == 'a' && s.charAt(s.length() - 2) == 'v' && s.charAt(s.length() - 1) == 'a') ...
```


```
a. if (s.endsWith("Java")) ...
c. if (s.substring(s.length() - 4).equals("Java")) ...
e. if (s.charAt(s.length() - 4) == 'J' && s.charAt(s.length() - 3) == 'a' && s.charAt(s.length() - 2) == 'v' && s.charAt(s.length() - 1) == 'a') ...
s.lastIndexOf("Java") >= 0 does not indicate that Java is the suffix of the string.
```

Computer Science & Information Technology

You might also like to view...

Which of the following statements is false?

a. Classes (and their objects) encapsulate, i.e., encase, their attributes and methods. b. A class’s (and its object’s) attributes and methods are intimately related. c. For objects to communicate effectively with one another, each must know how the other object is implemented. d. Information hiding is crucial to good software engineering.

Computer Science & Information Technology

One way to iterate through a Map is

A) to obtain the Map's iterator and use it B) to obtain the set of keys for the stored elements, and then iterate through that set of keys C) to use an integer index in a for loop to step through the elements D) None of the above

Computer Science & Information Technology

?To align a selected text to the right on a Microsoft PowerPoint slide, click the _________ tab on the ribbon,and then in the Paragraph group, click theAlign Rightbutton. ?A. Home B. Review C. Insert D. Design

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A(n) ____ is a program that does not come from a trusted source.

A. authorized Java applet B. unauthorized Java applet C. signed Java applet D. unsigned Java applet

Computer Science & Information Technology