Chapter 3 Test Study Guide

Description

Note on Chapter 3 Test Study Guide, created by Terri FLetcher on 16/02/2016.
Terri FLetcher
Note by Terri FLetcher, updated more than 1 year ago
Terri FLetcher
Created by Terri FLetcher over 8 years ago
56
0

Resource summary

Page 1

Chapter 3 Test Study Guide1. The "less than or equal to" comparison operator in Java is __________. A. < B. <= C. =< D. << E. !=2. The equal comparison operator in Java is __________. A. <> B. != C. == D. ^=3. What is 1 + 1 + 1 + 1 + 1 == 5? A. true B. false C. There is no guarantee that 1 + 1 + 1 + 1 + 1 == 5 is true.4. What is 1.0 + 1.0 + 1.0 + 1.0 + 1.0 == 5.0? A. true B. false C. There is no guarantee that 1.0 + 1.0 + 1.0 + 1.0 + 1.0 == 5.0 is true.5. Which of the following code displays the area of a circle if the radius is positive. A. if (radius != 0) System.out.println(radius * radius * 3.14159); B. if (radius >= 0) System.out.println(radius * radius * 3.14159); C. if (radius > 0) System.out.println(radius * radius * 3.14159); D. if (radius <= 0) System.out.println(radius * radius * 3.14159);6. Suppose x = 1, y = -1, and z = 1. What will be displayed by the following statement? (Please indent the statement correctly first.)if (x > 0) if (y > 0) System.out.println("x > 0 and y > 0");else if (z > 0) System.out.println("x < 0 and z > 0"); A. x > 0 and y > 0 B. x < 0 and z > 0 C. x < 0 and z < 0 D. none7. What is the output of the following code?int x = 0;if (x < 4) { x = x + 1;}System.out.println("x is " + x); A. x is 0 B. x is 1 C. x is 2 D. x is 3 E. x is 48. The following code displays ___________.double temperature = 50;if (temperature >= 100) System.out.println("too hot");else if (temperature <= 40) System.out.println("too cold");else System.out.println("just right"); A. too hot B. too cold C. just right D. too hot too cold just right9. Suppose income is 4001, what is the output of the following code:if (income > 3000) { System.out.println("Income is greater than 3000");}else if (income > 4000) { System.out.println("Income is greater than 4000");} A. no output B. Income is greater than 3000 C. Income is greater than 3000 followed by Income is greater than 4000 D. Income is greater than 4000 E. Income is greater than 4000 followed by Income is greater than 300010. The __________ method immediately terminates the program. A. System.terminate(0); B. System.halt(0); C. System.exit(0); D. System.quit(0); E. System.stop(0);11. Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and "Can get a driver's license" if age is greater than or equal to 16. Which of the following code is correct?I: if (age < 16) System.out.println("Cannot get a driver's license");if (age >= 16) System.out.println("Can get a driver's license");II:if (age < 16) System.out.println("Cannot get a driver's license");else System.out.println("Can get a driver's license");III:if (age < 16) System.out.println("Cannot get a driver's license");else if (age >= 16) System.out.println("Can get a driver's license");IV:if (age < 16) System.out.println("Cannot get a driver's license");else if (age > 16) System.out.println("Can get a driver's license");else if (age == 16) System.out.println("Can get a driver's license"); A. I B. II C. III D. IV12. Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and "Can get a driver's license" if age is greater than or equal to 16. Which of the following code is the best?I: if (age < 16) System.out.println("Cannot get a driver's license");if (age >= 16) System.out.println("Can get a driver's license");II:if (age < 16) System.out.println("Cannot get a driver's license");else System.out.println("Can get a driver's license");III:if (age < 16) System.out.println("Cannot get a driver's license");else if (age >= 16) System.out.println("Can get a driver's license");IV:if (age < 16) System.out.println("Cannot get a driver's license");else if (age > 16) System.out.println("Can get a driver's license");else if (age == 16) System.out.println("Can get a driver's license"); A. I B. II C. III D. IV13. Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative? A. 1 < x < 100 && x < 0 B. ((x < 100) && (x > 1)) || (x < 0) C. ((x < 100) && (x > 1)) && (x < 0) D. (1 > x > 100) || (x < 0)14. Assume x = 4 and y = 5, Which of the following is true? A. x < 5 && y < 5 B. x < 5 || y < 5 C. x > 5 && y > 5 D. x > 5 || y > 515. Assume x = 4, Which of the following is true? A. !(x == 4) B. x != 4 C. x == 5 D. x != 516. Assume x = 4 and y = 5, Which of the following is true? A. !(x == y) B. x != y C. x == y D. x >= y17. Which of the following is equivalent to x != y? A. ! (x == y) B. x > y && x < y C. x > y || x < y D. x >= y || x <= y18. Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x-- > 10)? A. 9 B. 10 C. 1119. Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) && (x++ > 10). A. 9 B. 10 C. 1120. Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x-- > 10). A. 9 B. 10 C. 1121. Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x++ > 10). A. 9 B. 10 C. 1122. Analyze the following code:if (x < 100) && (x > 10) System.out.println("x is between 10 and 100"); A. The statement has compile errors because (x<100) & (x > 10) must be enclosed inside parentheses. B. The statement has compile errors because (x<100) & (x > 10) must be enclosed inside parentheses and the println(?) statement must be put inside a block. C. The statement compiles fine. D. The statement compiles fine, but has a runtime error.23. The order of the precedence (from high to low) of the operators binary +, *, &&, || is: A. &&, ||, *, + B. *, +, &&, || C. *, +, ||, && D. ||, &&, *, +24. What is y displayed in the following code?public class Test1 { public static void main(String[] args) { int x = 1; int y = x = x + 1; System.out.println("y is " + y); }} A. y is 0. B. y is 1 because x is assigned to y first. C. y is 2 because x + 1 is assigned to x and then x is assigned to y. D. The program has a compile error since x is redeclared in the statement int y = x = x + 1.25. Which of the following operators are right-associative. A. * B. + (binary +) C. % D. && E. =

Show full summary Hide full summary

Similar

Constitutional Law
jesusreyes88
BIOLOGY B1 2
x_clairey_x
Biology AQA 3.1.3 Cells
evie.daines
GCSE Revision: Christianity
Andrea Leyden
Psychology flashcards memory
eharveyhudl
Science Additional B3 - Animal and Plant Cells Flashcards
Stirling v
Maths
xcathyx99
Latin Literature Exam Techniques
mouldybiscuit
Plant Anatomy Quiz
Kit Sinclair
TISSUE TYPES
Missi Shoup