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; 



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

1 Expert Approved Answer
Step: 1 Unlock

H Printed once because its at index 0 Printed again because its at index 0 and the coun... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!