2551.quiz3.Spring2010

2551.quiz3.Spring2010 - count = 1; while (count...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 2551 – Quiz #3 Fall 2009 2007 Name: ___________________ Directions : Circle the True or False; write in the letter for multiple choice on the dotted line. 1. (True, False)………. . The value of a condition in an IF or a While is boolean, which means it evaluates to either true or false. 2. (True, False). ......... The switch statement can take a character as the expression to be evaluated. 3. (True, False)…… To compare integer variables or float variables for equality to each other, the proper choice of operators is the ==, as in if (float1 == float2) then …. 4. (True, False) …. . Lower case letters sort ‘higher’ than upper case letters due to their internal bit configurations. 5-6. To compare two string values, countryName1 and countryName2, please write the appropriate ‘if statement’” if ( ) (fill in the code needed to compare the two. 7. (True, False) Both the while statement and the for statement have a pre-test, but the do…while statement does not. Given the code:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: count = 1; while (count < 5) { System.out.printlin (I love COP 2551 \n); count ++; } // end while 8. What is the value of count when the loop ends? ___________________ 9. How many times does the body of the loop execute? _______________ 10-12. Write a while loop that sums the first 100 positive even integers. Start with 2. 13-15. Same as previous problem. Use a for loop. 16-18. Same; use a dowhile loop Bonus questions: Given the code: count1 = 1; while (count1 <= 5) { count2 = 1; while (count2 <= 10) { System.out.println ("Here"); count2++; }// end inner while count1++; } // end out while 19. How many times will the outer while execute? 20. How many times will the inner while execute? 21. .How many times will Here be printed? 22-23. What output is produced by the following code fragment? int num = 30, max = 5; if (num >= max*2) System.out.println (apple); System.out.println (orange); System.out.println (pear); Output is:...
View Full Document

Page1 / 2

2551.quiz3.Spring2010 - count = 1; while (count...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online