Which symbol correctly completes the following variable declaration?
char c = _g_;
"
%
+
-
'
Front
'
Back
What is the output?
System.out.println("Hello, \tWorld");
Front
Hello,
World
Back
What is output by the following code?
int val = -2;
val++;
val--;
val++;
val++;
val++;
val--;
val++;
0, 1, 2, 3, 4, 5
Front
1
Back
What is the output from: ifElseMystery(10, 3);
public static void ifElseMystery(int a, int b){
if(a < b){
a = a * b;
}
if(a > b){
a = a - 10;
}else{
b++;
}
System.out.println(a + " " + b);
}
Front
0 3
Back
Evaluate: 54 % 10 + 8 * 3 % 9
Front
10
Back
Which of the following is NOT a primitive data type?
boolean
double
int
String
char
Does the following code need a cast? ______ If so, what should you type to cast? ______
int val = 13.2;
no, none
yes, (decimal)
yes, (double)
yes, (int)
yes, (char)
Front
yes, (int)
Back
The following code is intended to input three integers and print the average. What is a potential problem with the code as written?
System.out.println("please enter three digits");
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
System.out.println("The answer is: " 1.0*a + b + c / 3);
1. It needs ( ) so the order of operations happens correctly.
2. No correction needed, the code will work as written.
3. It should be divided by 2, not 3.
4. It should use scan.nextDouble instead of scan.nextInt.
5. The parenthesis are not needed and will cause a mathematical error.
Front
1
Back
What is output by the following code?
int c = 3 - 37 % 1;
System.out.printlin(c);
Front
2;
Back
Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a double?
double val = scan.nextValue();
double val = scan.nextDouble;
double val = scan.nextDouble();
double val = nextDouble();
double val = scan.nextLine();
Front
double val = scan.nextDouble();
Back
Which of the following needs a cast?
char stored in an int variable
double stored in an int variable
char stored in a String variable
int stored in a double variable
char stored in a double variable
Front
double stored in an int variable
Back
QOD.1 What is the output of the following code?
int a = 10;
int b = 5,
for(int i = 0; i < a; i+=2){
for(int j = 0; j <= i % b; j++){
System.out.print("* ");
}
System.out.println();
}
Front
**
**
*
*
Back
Considering the following code, which option is an example of short circuit evaluation?
if(a < b && c != d)
1. if a < b is true it doesn't evaluate c != d
2. if a < b is false it doesn't evaluate c != d
3. if c != d is false it evaluates a < b
4. if c != d is true it doesn't evaluate a < b
5. if a < b is true it evaluates c != d
Front
if a < b is false it doesn't evaluate c != d
Back
Convert 54 to binary
Front
110110
Back
In Java all output uses the ______ data type.
int
scan
String
double
char
Front
String
Back
Evaluate: 2.3 * 3 + 19 / 5 / 2 + 6.0 / 5
Front
9.1
Back
Which character below is not allowed in a variable name?
W
q
3
&
Front
&
Back
Put the following data types in order from smallest to largest (in terms of memory used)
1. double, char, int, String
2. int, char, double, String
3. char, int, double, String
4. double, int, char, String
5. int, double, char, String
Front
3
Back
Evaluate: 10 - 5 5 (2 - 6 + 8)
Front
-90
Back
Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a double?
double val = scan.nextValue();
double val = scan.nextDouble;
double val = scan.nextDouble();
double val = nextDouble();
double val = scan.nextLine();
Front
double val = scan.nextDouble();
Back
What is output?
int a = 91;
System.out.println(a/2);
Front
45
Back
What are if statements used for in programs?
Repeating commands
Storing data
Numeric calculations
Numeric casts
Making decisions
Front
Making decisions
Back
Which of the following correctly stores the word umbrella in a variable called stuff?
String umbrella = "stuff";
String "stuff" = "umbrella";
String stuff = umbrella;
String stuff = "umbrella";
String umbrella = stuff;
Front
String stuff = "umbrella";
Back
Evaluate: 3 2 + 4 + "+" + 2 + 3 4 *
Front
10+212
Back
Which of the following variable assignments is legal in Java?
double n = 3;
int x = 5.0/2;
int q = 82.3847;
char l = "G";
Front
double n = 3;
Back
Which if statement below tests if letter holds J? (letter is a char)
if ( letter == 'J')
if ( letter == J)
if ( letter >= 'J')
if ( letter = 'J')
if ( letter == "J")
Front
if ( letter == 'J')
Back
What is the output of the following code?
double x = -97.6;
System.out.println(Math.abs(x));
-98
-97.6
-96
97.6
98
Front
97.6
Back
Convert 0110 1001 to decimal
Front
105
Back
Correct the following code: char q = -82;
char q = (char)Math.sqrt(-82);
char q = int(-82);
char q =(int) -82;
char q =(char)Math.abs(-82);
No changes, the code is fine.
Front
char q = int(-82);
Back
Which is the best way to avoid roundoff error?
1. Use booleans for calculations.
2. Convert double values to ints and do calculations using integers.
3. Convert int values to doubles and do calculations using doubles.
4. Convert char values to doubles and do calculations using doubles.
5. Do all calculations using doubles.