hello quizlet
Home
Subjects
Expert solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
MIS 3330 - Chapter 3 Review Qs
Flashcards
Learn
Test
Match
Flashcards
Learn
Test
Match
Terms in this set (44)
3.1 The "less than or equal to" comparison operator in Java is __________.
A. <
B. <=
C. =<
D. <<
E. !=
B. <=
3.2 The equal comparison operator in Java is __________.
A. <>
B. !=
C. ==
D. ^=
C. ==
3.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.
A. true
3.4 What is 1 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5?
A. true
B. false
C. There is no guarantee that 1 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5 is true.
C. There is no guarantee that 1 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1 == 0.5 is true.
3.5 In Java, the word true is ________.
A. a Java keyword
B. a Boolean literal
C. same as value 1
D. same as value 0
B. a Boolean literal
3.6 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);
C. if (radius > 0) System.out.println(radius
radius
3.14159);
3.7 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 4
B. x is 1
3.8 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 3000
B. Income is greater than 3000
3.9 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 right
C. just right
3.10 Suppose x = 1, y = -1, and z = 1. What is the output of 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. no output.
B. x < 0 and z > 0;
3.11 Analyze the following code: boolean even = false;
if (even = true) {
System.out.println("It is even");
}
A. The program has a compile error.
B. The program has a runtime error.
C. The program runs fine, but displays nothing.
D. The program runs fine and displays It is even.
D. The program runs fine and displays It is even.
3.12 Suppose isPrime is a boolean variable, which of the following is the correct and best statement for testing if isPrime is true?
A. if (isPrime = true)
B. if (isPrime == true)
C. if (isPrime)
D. if (!isPrime = false)
E. if (!isPrime == false)
C. if (isPrime)
3.13 Analyze the following code.
boolean even = false;
if (even) {
System.out.println("It is even!");
}
A. The code displays It is even!
B. The code displays nothing.
C. The code is wrong. You should replace if (even) with if (even == true).
D. The code is wrong. You should replace if (even) with if (even = true).
B. The code displays nothing.
3.14 Analyze the following code:
Code 1:
int number = 45;
boolean even;
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
int number = 45;
boolean even = (number % 2 == 0);
A. Code 1 has compile errors.
B. Code 2 has compile errors.
C. Both Code 1 and Code 2 have compile errors.
D. Both Code 1 and Code 2 are correct, but Code 2 is better.
D. Both Code 1 and Code 2 are correct, but Code 2 is better.
3.15 Which of the following is a possible output from invoking Math.random()?
A. 3.43
B. 0.5
C. 0.0
D. 1.0
B. 0.5 & C. 0.0
3.16 What is the output from System.out.println((int)Math.random() * 4)?
A. 0
B. 1
C. 2
D. 3
E. 4
A. 0
3.17 What is the possible output from System.out.println((int)(Math.random() * 4))?
0, 1, 2, 3, 4
3.18 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?
...
3.19 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?
B. II
3.20 The __________ method immediately terminates the program.
C. System.exit(0);
3.21 Which of the Boolean expressions below is incorrect?
B. ((x < 100) && (x > 1)) || (x < 0) B. x != 4 ^ y == 5 C. x <= 4 && x >= -4
3.22 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?
B. ((x < 100) && (x > 1)) || (x < 0)
3.23 Assume x = 4 and y = 5, which of the following is true?
B. x < 5 || y < 5
3.24 Assume x = 4, which of the following is true?
D. x != 5
3.25 Assume x = 4 and y = 5, which of the following is true?
B. x != 4 ^ y == 5
3.26 Given |x| <= 4, which of the following is true?
C. x <= 4 && x >= -4
3.27 Given |x| >= 4, which of the following is true?
B. x >= 4 || x <= -4
3.28 Which of the following is equivalent to x != y?
B. 10 B. 10
3.29 Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x-- > 10)?
B. 10
3.30 Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x++ > 10).
B. 10
3.31 Suppose x=10 and y=10. What is x after evaluating the expression (y >= 10) || (x-- > 10).
B. 10
3.32 Suppose x=10 and y=10. What is x after evaluating the expression (y >= 10) || (x++ > 10).
B. 10
3.33 Analyze the following code:
A. The statement has compile errors because (x<100) & (x > 10) must be enclosed inside parentheses.
3.34 Which of the following are so called short-circuit operators?
B. 2 A. -10
3.35 What is y after the following switch statement is executed?
B. 2
3.36 Analyze the following program fragment:
C. The switch control variable cannot be double.
3.37 What is y after the following statement is executed?
A. -10
3.38 Analyze the following code fragments that assign a boolean value to the variable even.
E. All three are correct, but Code 3 is preferred.
3.39 What is the output of the following code?
B. false
3.40 The order of the precedence (from high to low) of the operators binary +, *, &&, ||, ^ is:
C. *, +, ^, &&, ||
3.41 What is y displayed in the following code?
C. y is 2 because x + 1 is assigned to x and then x is assigned to y.
3.42 Which of the following operators are right-associative.
E. =
3.43 What is the value of the following expression?
A. true
3.44 Which of the following statements are true?
A. (x > 0 && x < 10) is same as ((x > 0) && (x < 10)) B. (x > 0 || x < 10) is same as ((x > 0) || (x < 10)) C. (x > 0 || x < 10 && y < 0) is same as (x > 0 || (x < 10 && y < 0))
Students also viewed
Chapter 3 Quiz
44 terms
Chapter 5
21 terms
Chapter 4 Quiz
46 terms
javaCh3
75 terms
Sets found in the same folder
Chapter 3 Quiz
44 terms
Chapter 2 Quiz
30 terms
CIS225 Ch. 8
22 terms
D8 - M
31 terms
Other sets by this creator
Chapter 6
10 terms
Chapter 5
10 terms
Chapter 4
10 terms
Chapter 3
10 terms
Verified questions
applied math
Show that the congruence $x^{3} \equiv 3(\bmod 19)$ has no solutions, whereas $x^{3} \equiv 11(\bmod 19)$ has three incongruent solutions.
applied math
a) Create a quadratic model for the height of a toy rocket launched upward at 45 m/s from a 2-m platform. b) How long would the rocket take to fall to Earth, rounded to the nearest hundredth of a second?
applied math
Find the value of the following Legendre symbols: (a) (19/23). (b) (-23/59). (c) (20/31). (d) (18/43). (e) (-72/131).
applied math
The basket-of-eggs problem is often phrased in the following form: One egg remains when the eggs are removed from the basket 2, 3, 4, 5, or 6 at a time; but, no eggs remain if they are removed 7 at a time. Find the smallest number of eggs that could have been in the basket.
Recommended textbook solutions
Numerical Analysis
9th Edition
J. Douglas Faires, Richard L. Burden
873 solutions
Book of Proof
2nd Edition
Richard Hammack
340 solutions
Introductory Combinatorics
5th Edition
Richard A. Brualdi
685 solutions
Numerical Analysis
8th Edition
J. Douglas Faires, Richard L. Burden
775 solutions
Other Quizlet sets
Somatosensory System
52 terms
The Nervous System
61 terms
Band Saw Safety
11 terms