Given
String name;
the value of name is directly stored in its memory space. - Answers False
String objects are immutable. - Answers True
Contents of the java.util package do not need to be imported into a program in order to be used. -
Answers False
In order to use a predefined method, you simply need to know the name of the method. - Answers False
The method length in the class String returns the number of characters in the string including
whitespace characters. - Answers True
The method printf is used only to format the output of decimal numbers. - Answers False
The default output of decimal numbers of the type float is up to 15 decimal places. - Answers False
A string consisting of only an integer or a floating-point number is called a numeric string. - Answers
True
The method parseInt is used to convert a numeric integer string into a value of the type double. -
Answers False
The classes Integer, Float, and Double are not wrapper classes. - Answers False
Which of the following is a valid statement? - Answers String name = "Doe";
In Java, all variables declared using a class are ____. - Answers reference variables
Suppose str is a String variable. The statement
str = new String("Hello World");
is similar to which of the following? - Answers str = "Hello World";
Which statement instructs a program to run the garbage collector? - Answers System.gc();
, Suppose that str is a String variable. Write a Java statement that uses the operator new to instantiate
the object str and assign the string "Java Programming" to str. - Answers str = new String ("Java
Programming");
There are ____ types of methods in a class. - Answers 2
Which package is automatically imported by the Java system? - Answers java.lang
What is the value of the following statement?
Math.pow(3,2) - Answers 9.0
What will most probably happen if you omit the dot (.) operator when accessing a method? - Answers A
syntax error will be reported.
An expression such as str.length(); is an example of a(n) ____. - Answers method call
Which of the following outputs 56734.987 to three decimal places? - Answers System.out.printf("%.3f",
56734.98745);
What is the output of the following statement?
System.out.printf("%.3f", 56.1); - Answers 56.100
The method compareTo belongs to which class? - Answers String
A static method can be called using the name of the class containing the method, and a method must be
called in order to be executed - Answers True
To force the output to be right justified, you use the format specifier flag. If the flag is set to '-', then the
output of the result is right justified. - Answers False
If console is a Scanner object initialized to the standard input device, then the expression
console.nextDouble() retrieves the next string form the standard input device. - Answers False
If console is a Scanner object initialized to the standard input device, then the expression
console.nextInt() retrieves the next character from the standard input device. - Answers False
If console is a Scanner object initialized to the standard input device, then the expression console.next()
retrieves the next character from the standard input device. - Answers False
If console is a Scanner object initialized to the standard input device, then the expression
console.nextDouble() retrieves the next _______from the standard input device. - Answers floating
number
Suppose console is a Scanner object initialized with the standard input device. The expression
console.nextInt(); is used to read one int value and the expression console.nextDouble(); is used to read
two double values. - Answers False