Developing Algorithms Using Strings

AP Computer Science A· difficulty 3/5

What's printed for s = "abcd"?

<code>for (int i = 0; i < s.length(); i += 2) System.out.print(s.charAt(i)); </code></pre>

  • A

    ac

    check_circle
  • B

    ab

  • C

    bd

  • D

    abcd

Explanation

i = 0, 2: 'a', 'c'.

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

Related questions