id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

sspiege3@schools.nyc.gov magpieactivity3hwb

What is the output of the following code segment?

String phrase = "Here is the word"; int psn = phrase.indexOf("e"); while (psn >= 0) { System.out.print(psn); phrase = phrase.substring(psn + 1); psn = phrase.indexOf("e"); }

(A) 116

(B) 227

(C) 1310

(D) 2411

(E) Many digits will be printed due to an infinite loop.

Questions to code

doubleChar H   // a loop will be necessary to build up the string (see hint in question)

countHi H   //a loop problem too. Please use today's code as a guide. (hint in question does not align with Magpie)

vowel  //There is a way to do this elegantly without multiple if statements

isBeforeJava 
Authoring docs

Copyright Nick Parlante 2017 - privacy