Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2) Which of the following is not an example of an unchecked exception? A) IOExce

ID: 638113 • Letter: 2

Question

2)        Which of the following is not an example of an unchecked exception?

A) IOException

B) NullPointerException

C) NumberFormatException

D) InputMismatchException

3)         To declare that a method should be terminated when a checked exception occurs within it, you should tag the method with a(n) ____ specifier.

A) catch

B) try

C) unchecked

D) throws

4) Which of the following statements is correct?

A) public void read(String filename) throws IOException, ClassNotFoundException

B) public void read(String filename) throw IOException, ClassNotFoundException

C) public void read(String filename) throw (IOException, ClassNotFoundException)

D) public void read(String filename) throws IOException, throws ClassNotFoundException

5) The compiler does not check whether you handle a(n) ____.

A) NullPointerException

B) FileNotFoundException

C) EOFException

D) IOException

6) The Scanner.nextInt method throws an unchecked ____ if a user enters an input that is not an integer.

A) InputMismatchException

B) NumberFormatException

C) IllegalArgumentException

D) IOException

7) Once a try block is entered, the statements in a(n) ____ clause are guaranteed to be executed, whether or not an exception is thrown.

A) catch

B) String

C) close

D) finally

8) Which of the following can be used to record the behavior of classes?

A) Javadoc comments

B) Nouns and verbs in the problem description

C) Polymorphism

D) UML notation

9) An interface does not have ____.

A) return types

B) instance fields

C) abstract methods

D) public methods

10) . In Java, ____ can be used for listeners.

A) objects

B) interfaces

C) any class

D) operators

11) Which of the following statements is correct?

A) An inner class inside a method is a publicly accessible feature.

B) An interface is also a class.

C) A class can extend at least two superclasses.

D) You can define an inner class inside an enclosing class, but outside its methods.

12) An abstract class can

A) implement an interface

B) extend another abstract class

C) extend another regular class

D) A and B

E) A and C

13) Suppose listener is an instance of a class that implements the WindowListener interface. How many methods does listener have?

A) 0

B) 1

C) at least 7

D) at most 7

14) Which of the following statements is correct?

A) Interfaces are classes.

B) A class can implement more than one interface type.

C) All fields in an interface are private.

D) A class can implement only one interface type.

15)

Based on the code below, which of the following statements is correct?

public interface Measurable

{

double getMeasure();

}

public class Coin implements Measurable

{

public double getMeasure()

{

return value;

}

...

}

public class DataSet

{

...

public void add()

{

...

}

}

public class BankAccount

{

...

public void add()

{

...

}

}

A)

Coin dime = new Coin(0.1, "dime");

Measurable x = dime;

B)

Coin dime = new Coin(0.1, "dime");

Dataset x = dime;

C)

Coin dime = new Coin(0.1, "dime");

DataSet x == dime;

D)

Coin dime = new Coin(0.1, "dime");

BankAccount x = dime;

16) Define an interface type Colorable that returns the color of the object and sets the color of the object. (4pts)

void showInfo(Person p) {

Student s = (Student) p;

System.out.println(

Explanation / Answer

1)

1 t
2 t
3 f
4 f
5 t
6 f
7 t
8 t
9 f
10 t
11 f
12 t
13 t
14 f
15 t
16 f
17 f
18 f
19 t
20 t

2)D

3)A

4)C
5)C
6) B
7)D
8)D
9)B
10) A
11)A
12)D
13)B
14)B
15)B
16)1
20)B

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote