FinalExamA - 1 CMPS 12A - Winter 2002 Final Exam A March...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 1 CMPS 12A - Winter 2002 Final Exam A March 16, 2002 Name:__________________________________________ID:____________________________ This is a closed note, closed book exam. Any place where you are asked to write code, you must declare all variables that you use. However, I just want code fragments, you must not write extra code such as a class specification or extraneous print statements. Section I: 20 multiple choice questions [5 points each] For each of the following questions, write the letter of the best answer to the right of the question including, where appropriate, All for All of the above or None for None of the above. 1. The purpose of testing is to make sure your program: a. Does what it is supposed to do b. Doesn't do what it is not supposed to do c. Does what it used to do 2. Which are all Java keywords: a. int, double, for, array, and break b. continue, break, main, switch, and float c. char, boolean, final, static, and this 3. Which are all valid identifiers: a. Change, 7eleven, m77, foo_bar b. float, a, sIlLy, data? c. main, seven11, a$, test_case, java 4. Which are valid literals a. 5L, 3.7, '\n', "(&(#@" b. 23, 4.5, -0.01, 'abc', "12897a*&)U" c. 5, 4-5, 0.0000004, ';', "Hello" 5. The type of a variable specifies: a. its value b. its name c. the operations that are permitted on it 6. char a = 'a'; a++; a is equal to: a. 'b' b. b c. error All C - array and main are not keywords C - 7eleven and data? are not valid identifiers A - abc and 4-5 are not valid lit- erals, but 5L is C A 2 1. Which of the following results in a = = 0 a. int a = 3/4; b. int a = 3.0/4.0; c. double a = 3/4; 2. If a = 1 and b = 23, what does this expression print out if(!( (1+2*a == 3) && (b-23+a != 1) )) System.out.println("false"); else System.out.println("true"); a. true b. false c. nothing 3. Which list of operators is listed in order of precedence a. +, *, /, = b. ++, *, +, = c. &&, *, +, % 4. What is the value of the expression (3+4*5 - 4*5+3) a. b. 12 c. 3 5. Given a = 5 and b = 7, what does this code print out if (b < a) System.out.println("1"); else if (a + 2 == b) System.out.println("2"); else if (a < b) System.out.println("3"); a. 1 b. 2 c. 3 d. both 2 and 3 e. nothing 6. What does this code print out: int a = 'b'; switch(a) { case 'a': System.out.println('1'); case 'b': System.out.println('2'); case 'c': System.out.println('3'); } a. 1 b. 2 c. 3 d. both 2 and 3 e. nothing 7. Which of the following results in a = = 0 a. int a = 3/4; b. int a = 3.0/4.0; c. double a = 3/4; 8. If a = 1 and b = 23, what does this expression print out if(!( (1+2*a == 3) && (b-23+a != 1) )) System.out.println("false"); else System.out.println("true"); a. true b. false c. nothing 9. Which list of operators is listed in order of precedence a. +, *, /, = b. ++, *, +, = c. &&, *, +, % 10. What is the value of the expression (3+4*5 - 4*5+3) a....
View Full Document

Page1 / 27

FinalExamA - 1 CMPS 12A - Winter 2002 Final Exam A March...

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

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