Consider the following code. What is the value of z?
int x = 7;
int y = 3;
double z = x / y + 0.5;
Loading test…
12 questions
Consider the following code. What is the value of z?
int x = 7;
int y = 3;
double z = x / y + 0.5;
What is the result of the following expression in Java?
int result = 3 + 4 * 2 - 10 / 4;
What is the output of the following code?
int x = Integer.MAX_VALUE;
x = x + 1;
System.out.println(x > 0);
After the following code executes, what is the value of n?
double d = 7.9;
int n = (int) d % 3;
Which of the following correctly declares a boolean variable and assigns it the result of a comparison?
// Option A
boolean result = (7 > 3);
// Option B
Boolean result = 7 > 3;
// Option C
bool result = 7 > 3;
// Option D
boolean result = "7 > 3";
Which statement about Java primitive types is correct?
What is the value of result after this code runs?
int result = (int) 9.99;
What is the output of the following code?
int a = 2;
System.out.println(a++);
System.out.println(a);
What is the output of the following code?
int x = 10;
x += 3;
x *= 2;
x -= 7;
System.out.println(x);
What is printed by the following code?
double d = 1.0 / 3.0;
int i = (int)(d * 10);
System.out.println(i);
What is the output of the following code?
int a = 17;
int b = 5;
System.out.println(a / b);
System.out.println(a % b);
What are the values of x and y after the following code executes?
double x = 5 / 2;
double y = 5.0 / 2;