Twenty questions. Mostly multiple choice. A few short answer. Move through the questions with the arrows next to n of 20 in the question box.
What does the ln in System.out.println stand for?
Lane
Line
Alone
Natural log
How many lines does the following code print:
System.out.print("Hello");
System.out.println(", world!");
System.out.println("Goodbye!");
1
2
3
4
What’s a good data type to represent a temperature in degrees Celsius?
int
double
boolean
String
None of the above.
What’s a good data type to represent the number of teachers at BHS?
int
double
boolean
String
None of the above.
What’s a good data type to represent the number of dollars in your bank account?
int
double
boolean
String
None of the above.
What’s a good data type to represent text in almost any characters used by different languages around the world?
int
double
boolean
String
None of the above.
What’s a good data type to represent whether a senior is allowed to go to the prom?
int
double
boolean
String
None of the above.
What’s a good data type to represent the number of atoms in the universe?
int
double
boolean
String
None of the above.
Which of these is not an expression?
10
x
int y;
10.5
a + b * c
(int) n
"hello, world!"
Which of these is the correct way to compute the fraction of seniors in a section as a double given the int variables numberOfSeniors and totalNumberOfStudents?
(double) numberOfSeniors / totalNumberOfStudents
(double) (numberOfSeniors / totalNumberOfStudents)
Which of these is would also work to compute the fraction of seniors in a section as a double given the int variables numberOfSeniors and totalNumberOfStudents?
1.0 * numberOfSeniors / totalNumberOfStudents
numberOfSeniors / totalNumberOfStudents * 1.0
Which of these is the correct way to convert the double variable fractionSeniors to a percentage in the range 0 to 100 rounded to the nearest integer.
(int) (fractionSeniors * 100)
(int) fractionSeniors * 100
(int) fractionSeniors * 100 + 0.5
(int) (fractionSeniors * 100 + 0.5)
(int) (fractionSeniors + 0.5 * 100)
(int) (fractionSeniors + 0.5) * 100
Which if these is the correct expression to get the value of the digit in the one’s place of n?
n / 10
n % 10
n * 10
n / 10.0
What is the value of this expression:
6 - 12 / 3.0
Hit enter to save answer.
What is the value of this expression:
3 / 12 * 8.0
Hit enter to save answer.
What is the value of this expression:
7 - 2 % 3
Hit enter to save answer.
To compute the true mathematical modulus of a and b (what a % b would be if % was actually a modulus operator) you can compute the remainder of a divided by b, add b to that, and then and take the remainder of that whole thing when divided by b. Write an expression that implements that formula in Java using a and b as the two operands.
Hit enter to save answer.
What is x after the following code runs:
int x = 0;
x += 1;
x -= 10;
x *= -3;
x %= 5;
x = x * 2;
x--;
Hit enter to save answer.
This sequence of code will leave x with some final value that obviously depends on the initial value. Write a a single expression that computes the same final value without changing x.
x += 1;
x -= 10;
x *= -3;
x %= 5;
x = x * 2;
x--;
Hit enter to save answer.
Which kind of monster are double values like?
Giant spiders
Orcs
Zombies
Poltergeists