Java Exam #2 UPDATED ACTUAL Exam Questions and
CORRECT Answers
When the code in a try block may throw more than one type of exception, you need to write a
catch clause for each type of exception that could potentially be thrown.
True OR False - True
The illegalArgumentException class inherits from the RuntimeException class, and is therefore:
a. A checked exception class
b. An unchecked exception class
c. Never used directly
d. None of the above - b. An unchecked exception class
When you use a checked exception class, you must:
a. have a throws clause in the method heading
b. override the default error method
c. use each class only once in a method
d. ensure that the error will occur at least once each time the program is executed - a. have a
throws clause in the method heading
A class that has at least one abstract method is called an:
a. concrete class
b. encapsulated class
c. abstract class
d. private class - c. abstract class
Java allows an instance of an abstract class to be instantiated.
, True OR False - False.
An abstract class is a class that has some methods without complete definitions.
True OR False - True.
The FileNotFoundException is a descendant of the class IOException.
True OR False - True.
Look at the following code. (NOTE: The numbers on the left are for line identification.)
1 public interface Interface1
2{
3 int FIELDA = 55;
4 public int methodA(double){}
5}
Which line in the interface has an error?
a. 1
b. 2
c. 3
d. 4 - d. 4
Which of the following statements correctly specifies three interfaces?
a. public class ClassA implements Interface1, Interface2, Interface3
b. public class ClassA implements [Interface1, Interface2, Interface3]
c. public class ClassA implements (Interface1, Interface2, Interface3)
CORRECT Answers
When the code in a try block may throw more than one type of exception, you need to write a
catch clause for each type of exception that could potentially be thrown.
True OR False - True
The illegalArgumentException class inherits from the RuntimeException class, and is therefore:
a. A checked exception class
b. An unchecked exception class
c. Never used directly
d. None of the above - b. An unchecked exception class
When you use a checked exception class, you must:
a. have a throws clause in the method heading
b. override the default error method
c. use each class only once in a method
d. ensure that the error will occur at least once each time the program is executed - a. have a
throws clause in the method heading
A class that has at least one abstract method is called an:
a. concrete class
b. encapsulated class
c. abstract class
d. private class - c. abstract class
Java allows an instance of an abstract class to be instantiated.
, True OR False - False.
An abstract class is a class that has some methods without complete definitions.
True OR False - True.
The FileNotFoundException is a descendant of the class IOException.
True OR False - True.
Look at the following code. (NOTE: The numbers on the left are for line identification.)
1 public interface Interface1
2{
3 int FIELDA = 55;
4 public int methodA(double){}
5}
Which line in the interface has an error?
a. 1
b. 2
c. 3
d. 4 - d. 4
Which of the following statements correctly specifies three interfaces?
a. public class ClassA implements Interface1, Interface2, Interface3
b. public class ClassA implements [Interface1, Interface2, Interface3]
c. public class ClassA implements (Interface1, Interface2, Interface3)