1. If a class contains at least one abstract method, it is a(n) __________ class
ID: 3711281 • Letter: 1
Question
1. If a class contains at least one abstract method, it is a(n) __________ class.
2. Classes from which objects can be instantiated are called __________ classes.
For questions 3 through 9, state whether each of the statements is true or false. If false, explain why.
3. All methods in an abstract class must be declared as abstract methods.
4. Invoking a subclass-only method through a superclass variable is not allowed.
5. If a superclass declares an abstract method, a subclass must implement that method.
6. An object of a class that implements an interface may be though of as an object of that interface type.
7. An interface’s type can be used as an argument’s type in a method.
8. Abstract methods in an interface must use the abstract keyword.
9. Abstract classes do not have constructors.
10. The keyword __________ can be used to determine if a variable is actually a subclass type. 11. How can a programmer ensure that a class is never extended?
12. How can a programmer allow only certain methods in a class to be overridden, but not others?
13. If no exceptions are thrown in a try block, where does control proceed to when the try block completes execution?
14. Should a conventional application catch Error objects? Explain. 15. What is the key reason for using the finally block?
16. State whether the following exceptions are checked or unchecked exceptions. (Hint: You will need to know the inheritance hierarchy of each of these exception classes: its superclass, its superclass’s superclass, etc. This can be found near the top of the Javadoc documentation for each
Answers to the following questions can be found or determined by reading Chapters 10, 11, and 15 in the textbook. Unless otherwise stated, each question is worth 5 points.
Note: The sum of point totals for all questions is more than 100 points. Students who earn more than 100 points will receive extra credit.
class. Google should return the Javadoc of the class as the first result when you search for java 9 javadoc className, replacing className with the exception’s name.)
java.lang.ArithmeticException java.lang.ClassNotFoundException java.io.IOException java.lang.NumberFormatException java.sql.SQLException
17. Which class contains the format method for writing to a text file?
18. Which class can be used to retrieve Strings, numeric primitives, or full lines of text from a text
file?
19. Which interface must a class implement in order for its objects to be serialized? 20. Which class contains the writeObject method for serializing an object?
21. Which class contains the readObject method for deserializing an object?
Explanation / Answer
Answers)
1. If a class contains at least one abstract method, it is a(n) abstract class. - The abstract methods have to be implemented in order to the class not being called abstract, if an abstract method contains, then it is abstract class.
2. Classes from which objects can be instantiated are called concrete classes.
3. All methods in an abstract class must be declared as abstract methods. - False, as in an abstract class there will be non-abstract methods also as well as abstract methods.
4. Invoking a subclass-only method through a superclass variable is not allowed. - False, The above approach invoking a subclass-only method through a superclass variable is allowed
5. If a superclass declares an abstract method, a subclass must implement that method. - False, is not true as the subclass may not implement the abstract method. Then the subclass also becomes the abstract class.
6. An object of a class that implements an interface may be though of as an object of that interface type. - True
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.