String Methods

AP Computer Science A· difficulty 2/5

String s = "";
System.out.println(s.length());

What is printed?

  • A

    null

  • B

    Error

  • C

    0

    check_circle
  • D

    1

Explanation

The empty string contains zero characters, so length() returns 0.

Want 10 more like this — adaptive to your weak spots?

Related questions