Review Questions

10.16 Which of the following operators cannot be used in conjunction with a String object?

Select the two correct answers.

  1. +

  2. -

  3. +=

  4. .

  5. &

10.17 Which expression will extract the substring "kap" from a string defined by String str = "kakapo"?

Select the one correct answer.

  1. str.substring(2, 2)

  2. str.substring(2, 3)

  3. str.substring(2, 4)

  4. str.substring(2, 5)

  5. str.substring(3, 3)

10.18 What will be the result of attempting to compile and run the following code?
class MyClass {
    public static void main(String[] args) {
        String str1 = "str1";
        String str2 = "str2";
        String str3 = "str3";

        str1.concat(str2);
        System.out.println(str3.concat(str1));
    }
}

Select ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.