Computer Science
What is the Java operator that computes the remainder of an integer division?
%
What are the arithmetic operators (add, subtract, multiply, divide) in Java, respectively?
+, -, *, /
What is the result of a / b when variables a and b are declared as follows: int a = 9; int b = 5; ?
1.80
What is output by the code below? System.out.println( Math.pow( Math.sqrt(16),2) );
16
What is output by the code below? System.out.println( Math.round(5 / 2) );
3
What is the output by the code below? System.out.println( 3 + 6 );
9
What is the output by the code below? int x = 9; double y = x; System.out.println(y);
9.0
In Java, every program statement ends with a what ?
;
Which statement displays the correct average of the value of these variables of type int?
System.out.println( int1 + int2 / 2.0 );
Which of the following is the newline character?
\n
tab character
\t
What is the output by the code below? String s = "abcdef"; System.out.println( s );
abcdef
In Java, there are four integer primitive types with different ranges of integer values. Which ordering of the integer types lists the types in increasing order by range?
byte, short, int, long
What is the term that means to explicitly convert a value to a different type?
cast
What is the name of the operation denoted by the -- operator
decrement. (opps ++ increment)
In Java, which of the following is not an integer primitive type?
double
Which of the following types uses the most memory?
double
Which of the following correctly defines a constant in a method?
final double NICKEL_VALUE = 0.05;
Which of the following is a 32 bit data type?
int
Which of the following code fragments will compile without error?
int dollars = 100; double balance = dollars;
Which of the following statements is equivalent to items = items * 2; ?
items *= 2;
A numeric computation ___________ if the result falls outside the range for the number type.
overflows
In Java, every value is either a reference to an object, or it belongs to one of the eight________________________
primitive types
Sequence of characters
string
What is the value of x after the following sequence of statements?
x