What is the value of 17 / 5 in Java?
What is the value of 17 % 5?
What is the value of -17 / 5?
What is the value of -17 % 5?
What does 17.0 / 5 evaluate to?
What is the value of 2 + 3 * 4 - 6 / 3?
What is the value of 10 % 3 * 2?
Which expression correctly computes the average of two int variables a and
b as a double?
What is the output?
int i = 5;
int j = i++;
System.out.print(i + " " + j);
What is the output?
int i = 5;
int j = ++i;
System.out.print(i + " " + j);
What is the value of x after int x = 5; x = x++;?
What is the output?
int a = 3;
System.out.print(a++ + ++a);
What is the result of compiling and executing the following?
public class Question6 {
public static void main(String[] args) {
int meal = 2;
int tip = 4;
int total = meal + (meal > 1 ? ++tip : --tip);
System.out.println(tip);
}
}
In the previous question, what is the value of total?
Which line does not compile?
byte b = 10; // L1
b += 5; // L2
b = b + 5; // L3
b++; // L4
x *= 2 + 3; is equivalent to:
Which sequence shows the widening primitive conversions in the correct order?
Why does short c = a + b; fail to compile when a and b are short?
What is the value of (int) 9.99?
What is the value of (int) -9.99?
What does the following print?
System.out.println('a' + 1);
What does the following print?
System.out.println((char)('a' + 1));
Which cast is illegal in Java?
What is printed by System.out.println(1 + 2 + "3" + 4 + 5);?
What is printed by System.out.println("" + 1 + 2 * 3);?
What happens at run time when an int is divided by zero?
What is the value of 5.0 / 0?
Why is if (0.1 + 0.2 == 0.3) false?
What does n % 2 == 0 test?
What is the value of max after int a = 4, b = 9; int max = (a > b) ? a : b;?
In the conditional expression cond ? x++ : y++, how many of x and y are
incremented?
What is the output?
int total = 0;
for (int i = 1; i <= 3; i++) {
total += i * i;
}
System.out.print(total);
Which expression is equivalent to !(a > b) for numeric a and b?
What is the result of int x = (int)(7 / 2.0);?
An int variable holding 2147483647 is incremented by 1. What happens?
Explain, with one line of code each, the difference between
(double)(sum / count) and (double) sum / count when sum and count are both
int.
Why does b += 5 compile for a byte while b = b + 5
does not? Write the statement that the compiler effectively generates.
Trace int x = 2; int y = x++ * --x + x--; step by step and give
the final values of x and y.
Write a program SecondsConverter that stores a total number of
seconds (for example 9265) in an int and prints it in the form
2 h 34 min 25 s, using only integer division and the remainder operator.