Multiple-Choice
1.The name of a Java source file
(a)has no restrictions
(b)must be the same as the class it defines, ignoring case
(c)must use the extension .class
(d)must be the same as the class it defines, respecting case
2.Which of the following statements is (are) true about the use of an asterisk (*) in a Java
import statement?
Ⅰ.It does not incur run-time overhead.
Ⅱ.It can be used to import multiple packages with a single statement.
Ⅲ.It can be used to import multiple classes with a single statement
(a)I, II, and III
(b)I and III only
(c)I only
(d)III only
3.What is the name of the wrapper class for the type int?
(a) INT (b) integer (c) Integer (d) Int
4. A difference between the methods print and println of the class
java.io.PrintWriter is that
(a) println inserts a new line at the beginning of its output, but print does not
(b) print inserts a new line at the beginning of its output, but println does not
(c) print appends a new line to the end of its output, but println does not
(d) println appends a new line to the end of its output, but print does not
5. Consider the following Java program segment.
int x = 5;
int y = 2;
System.out.println(x + "1" + y);
Which of the following statements is true about the program segment?
(a)The output caused by the code will be 512.
(b)The output caused by the code will be 5 1 2.
(c)The output caused by the code will be 8.
(d)The code will cause a compilation error.
6. All Java exception classes are derived from the class
(a) http://www.doczj.com/doc/57ee6f1ea76e58fafab00312.htmlng.RuntimeException
(b) http://www.doczj.com/doc/57ee6f1ea76e58fafab00312.htmlng.Throwable
(c) http://www.doczj.com/doc/57ee6f1ea76e58fafab00312.htmlng.Error
(d) java.io.IOException
7. What is the right way to handle abnormalities in input on Java?
(a) By writing while loops to guard against bad input
(b) By handling these problems by providing exception handlers