If you want to buy this or Any Other Test Bank or Solution Manual contact us
1. Each class that implements an interface must provide the complete definition of all methods declared in the interface.
2. An interface is a class.
3. One way to make code reusable is to ____________________ or combine data elements together with methods that operate on that data in a separate program module.
4. The combination of data together with its methods is called a(n) ____________________ data type.
5. A Java ____________________ specifies the names, parameters, and return values of the ADT methods without specifying how the methods perform their operations or how the data is internally represented.
6. Method descriptions in an interface are called method ____________________.
7. The Javadoc program for Java documentation focuses on text that is enclosed with the delimeters ____________________.
8. A(n) ____ is a model of a physical entity or activity.
A) abstraction
B) interface
C) contract
D) use case
9. A Java interface is a(n) ____ between the interface designer and the programmer who codes a class that implements the interface.
A) precondition
B) postcondition
C) message
D) contract
10. A major reason for the popularity of object-oriented programming is that it enables programmers to reuse previously written code saved as classes.
11. An object that is a RuntimeException is an Exception. The converse is also true.
12. The has-a relationship between classes means that one class is a subclass of the other.
13. The is-a relationship between classes means that one class has the second class as an attribute.
14. The superclass of all Java classes is ____________________.
15. The ____________________ call in a class constructor invokes the superclass's constructor that has the corresponding argumentList.
16. Java automatically applies the ____________________ method to an object referenced in a String expression.
17. Having multiple methods with the same name but different signatures in a class is called ____________________.
18. A(n) ____________________ class is used to store a primitive-type value in an object type.
19. You should always override the ____________________ method if you want to represent an object's state.
20. In UML class diagrams, the ____ sign next to the method names indicate that the methods are public.
A) @
B) *
C) +
D) -
21. If no constructors are defined for a class, the ____ constructor for that class will be provided by default.
A) private
B) super
C) public
D) no-parameter
22. A data field (or method) with ____ visibility can be accessed in either the class defining it, in any subclass of that class, or any class in the same package.
A) private
B) protected
C) public
D) instanceof
23. The call to ____ invokes the constructor for the current class whose parameter list matches the argument list.
A) super()
B) super
C) this()
D) abstract
24. Which of the following statements is correct?
A) is-a and has-a relationships cannot be combined.
B) An abstract class can be instantiated.
C) An abstract class cannot declare abstract methods.
D) In Java, a variable of a superclass type can reference an object of a subclass type.
25. Which of the following statements is correct?
A) Interfaces can define instance variables and methods.
B) Abstract classes can define constants.
C) Interfaces can extend another class.
D) Instances of abstract classes can be created.
26. Which of the following methods of java.lang.Object compares an object to its argument?
A) boolean equals(Object obj)
B) int hashCode()
C) Object clone()
D) String toString()
27. The nextInt method will throw a(n) if an integer choice is not entered.
28. ArrayIndexOutOfBoundsException is thrown by the JVM when an index value used to access an element in an array is less than zero or greater than or equal to the array's length.
29. A ____________________ is thrown when the token returned by a Scanner next... method does not match the pattern for the expected data type.
A) ArithmeticException
B) IllegalArgumentException
C) InputMismatchException
D) NumberFormatException
30. ____________________ errors are mistakes in your use of the grammar of the Java language.
31. ____________________ errors occur during program execution .
32. The ____________________ is thrown when a program attempts to convert a nonnumeric string to a numeric value.
33. The class ____________________ is the superclass of all exceptions.
34. Which of the following would cause an ArrayIndexOutOfBounds error?
A) public boolean setElementOfX(int index, int val) { if(index >= 0 && index < x.length) { x[index] = val; return true; } else { return false; } }
B) public static void main(Strin[] args) { String inputFileName; if (args.length > 0)
inputFileName = args[0]; else
inputFileName = "Phone.dat"; }
C) for (int i = 0; i <x.length; i++) x[i] = i + i;
D) for (int i = 0; i <= x.length; i++) x[i] = i * i;
35. A(n) ____ is an error that is normally not due to programmer error and is beyond the control of the programmer.
A) checked exception
B) bug
C) syntax error
D) unchecked exception
36. Which of the following statements is correct?
A) If a checked exception is likely to be caught in a higher-level method, declare that it can occur using a catch clause.
B) If an exception is recoverable in the current method, handle the exception in the current method.
C) If an unchecked exception is is likely to be caught in a higher-level method, use a @catch tag to document this fact in the Javadoc comment for the method.
D) If an unchecked exception is likely to be caught in a higher-level method, declare that it can occur using a throws clause.
37. The ____ represent error conditions that may occur as a result of programmer error or as a result of serious external conditions that are considered unrecoverable.
A) unchecked exceptions
B) run-time error
C) checked exceptions
D) exception
38. Exception classes that are subclasses of ____ are unchecked.
A) EOFException
B) FileNotFoundException
C) IOException
D) RuntimeException
39. Which of the following is a RuntimeException?
A) AssertionErorr
B) FileNotFoundException
C) IllegalArgumentException
D) UnknownError
40. Classes that are not part of a package may access only ____________________ members of classes in the package.
41. ____________________ visibility is for members of a class that should not be accessible to anyone but the class, not even classes that extend it.
42. Which of the following is considered a visibility modifier in Java?
A) private
B) Inherit
C) Superclass
D) String
Answer Key
1. True
2. False
3. encapsulate
4. abstract
5. interface
6. declarations
7. /**, */
8. A
9. D
10. True
11. False
12. False
13. False
14. Object
15. super()
16. toString
17. method overloading overloading
18. wrapper
19. toString
20. C
21. D
22. B
23. C
24. D
25. B
26. A
27. InputMismatchException
28. True
29. C
30. Syntax
31. Runtime
32. NumberFormatException
33. Throwable
34. D
35. A
36. B
37. A
38. D
39. C
40. public
41. private
42. A