The purpose of a(n) ____________________ statement is to group several statements together to form a single statement.
Block
A (n) ____________________ defines a blueprint for creating objects with fields and methods.
Class
Which keyword is used to create a new object from a class?
New
!(a < b) is equivalent to ____________________.
a >= b
A variable defined within a class for which each instance has its own value is called a(n)
Instance Variable
A method that is called when an object is instantiated to initialize its fields is known as a(n)
Constructor
What does the this keyword refer to in a Java class?
The current instance (object) of the class.
Which of the following are primitive data types?
I. double
II. String
III. boolean
I and III only
Consider the following code segment.
int m = 8;
int n = 3;
if (m + n > 10)
{
System.out.print(m + n);
}
if (m - n > 0)
{
System.out.print(m - n);
}
What, if anything, is printed as a result of executing the code segment?
115
Consider the following code segment.
boolean a = true;
boolean b = false;
System.out.print((a == !b) != false);
What is printed as a result of executing this code segment?
A) false
B) true
C) truly false
D) Zisung
B
Hanmin is a Genius
True
A programmer needs to produce a random int n in the range 20 ≤ n ≤ 30. A statement that does this correctly is
A. int n = 10*Math.random() + 20;
B. int n = 11*Math.random() + 20;
C. int n = (int) (Math.random()) + 20;
D. int n = (int) (Math.random() * 11) + 20;
E. int n = (int) (Math.random() * 10) +
D
Write the Java version of the following pseudocode: If the student's grade is between 60 and 70 (inclusive), print "C".
if (grade >= 60 && grade <= 70) System.out.println("C");
make a code to solve this
Math.sqrt(Math.pow(x + y, 2) / Math.abs(a - b))
Assume that the following variable declarations have been made.
double d = Math.random();
double r;
What expression assigns a value to r from the uniform distribution over the range 0.5 ≤ r < 5.5 ?
r = d * 5.0 + 0.5;