Question: Consider the following JAVA code snippet: String greeting int count = 0; Hello!; for (int k = 0; k < greeting.length(); k++) { count
Consider the following JAVA code snippet: String greeting int count = 0; "Hello!"; for (int k = 0; k < greeting.length(); k++) { count += 1; letter = greeting.charAt (k) if (count & 2 == 0) System.out.println (greeting.charAt (k)); (letter); System.out.println System.out.println ("done"); Answer the following questions: 1) How many times does each of the characters H, e, 1, o and ! print out? 2) How many times does the string done print out?
Step by Step Solution
3.48 Rating (161 Votes )
There are 3 Steps involved in it
H Printed once because its at index 0 Printed again because its at index 0 and the coun... View full answer
Get step-by-step solutions from verified subject matter experts
