What is printed when mysteryaaa is executed

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: be true (ii) could be either true or false (iii) must be false t(n) = n3 (i) must be true (ii) could be either true or false (iii) must be false t(n) = 4n2.5 +17 (i) must be true (ii) could be either true or false (iii) must be false 4 [ CSE116 – EXAM 2 – VERSION 1 ] FALL 2011 Question 4 [10 marks] Part a [6 marks] Study the following code, then answer the questions which follow. public void mystery(String s) { int state = 1; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); System.out.print(state+”:“+c+” “); } } // NOTICE THE PRINT STATEMENT! switch (state) { case 1: if (c == 'A') { state = 2; break; } case 2: if (c == 'A') { state = 3; break; } else { state = 1; break; } case 3: if (c != 'A') { state = 1; break; } else { state = 1; break; } } What is printed when mystery(“ABC”); is executed? What is printed when mystery(“AAA”); is executed? Part b [4 marks] What is the access policy of...
View Full Document

This note was uploaded on 08/19/2013 for the course CSE 1156 taught by Professor Alhonce during the Fall '11 term at SUNY Buffalo.

Ask a homework question - tutors are online