Module 2
What is the result of the following expression?10 + 5 * 3 - 20
5
What is the value of z after the following statements have been executed? int x = 4, y = 33;double z;z = (double) (y / x);
8.0
Which of the following is NOT true about identifiers in Java?
Identifiers can contain white spaces
Which of the following statements correctly creates a Scanner object for keyboard input?
Scanner keyboard = new Scanner(System.in);
To print "Hello, world" on the monitor, which of the following Java statements should be used?
System.out.println("Hello, world");
For the following code, which statement is NOT true? public class Sphere { private double radius; public double x; private double y; private double z; }
The z field is available to code written outside the Sphere class.
What would be displayed as a result of executing the following code? int x = 578;System.out.print("There are " + (x + 5) + " hens in the hen house.");
There are 583 hens in the hen house.
It is common practice in object-oriented programming to make all of a class's
fields private.
The scope of a local variable is:
the method in which it is defined.
The primitive data types only allow a(n) ________ to hold a single value.
variable