QUESTION 1 Indicate the correct term for each definition in the given blanks. The terms are worth 1 point each. ✓ Default method Abstract class ✓ finally clause ✓try block ✓ Interface ✓ Abstract method ✓try-with-resources block ✓ Marker interface ✓ catch block ✓Call stack A. Contains statements that may throw an exception B. Used to provide an implemented method in an interface C. Interface with an empty body D. Used to automatically close a file E. Has a method header but no method body F. Contains statements for handling an exception G. Always executes regardless of whether or not an exception is thrown H. List of currently executing methods in a program 1. Contains only unimplemented methods J. Contains both implemented and unimplemented methods
QUESTION 2 Which of the following describes the relationship between an abstract class and its subclasses? A. has-a relationship B. strong is-a relationship C. weak is-a relationship O D. part-of relationship QUESTION 3 Which of the following describes the relationship between an interface and its subclasses? A. has-a relationship B. strong is-a relationship C. weak is-a relationship D.oart-of relationship QUESTION 4 Which of the following is the method used to access the message from an exception object? O A. getMessage B.printStackTrace C.getStackTrace O D.toString
QUESTION 5 Which of the following is the parent class for all exceptions that may be thrown while handling a file? O A. RunTimeException B.IOException C.FileNotFoundException O D. IllegalArgumentException QUESTION 6 What keyword indicates a method implemented in the JVM for the native platform? A. transient B. native C. abstract O D. default QUESTION 7 The Cloneable interface is a marker interface. O True O False
QUESTION 8 The default behavior of the PrintWriter class is to append new content to the end of a file. O True O False QUESTION 9 Checked exceptions inherit from the Error or RuntimeException classes. O True O False QUESTION 10 The Number abstract class is the parent class of classes such as Integer, Double, and BigDecimal. O True O False QUESTION 11 If you are catching multiple exceptions, the catch blocks must be ordered from most specific exception to most general exception. O True O False
QUESTION 12 The following code is the class header for the Banana class. The Banana class inherits the methods from the Edible interface. public class {...} For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph V Open Sans,sa... v P QUESTION 13 public int compare To (ComparableRectangle o) { if (getArea() return else if (getArea(). return } else return o.getArea()) 10pt o.getArea()) !!! < !!! < A Ix ǐ % 0 $1 10 points The following code is used to implement the compare To method in the ComparableRectangle class. This method returns 1 if the calling object has a greater area than the passed in object, -1 if the calling object has lesser area than the passed in object, and 0 if the objects have equal areas. Q 5 points 个 Save Answer ... O WORDS POWERED BY TINY Save Answer
10 points Assume an object of the Scanner class called inputFile was declared and is going to be used to read from the "Names.txt" file. If an IOException occurs, it should be caught and the error message should be printed to the console. Regardless of whether an Exception is caught or not, close the file. QUESTION 14 } } { inputFile = new Scanner(new File("Names.txt")); inputFile.nextLine(); e) { System.out.println(e. _()); { inputFile.close(); Save Answer
15 points The following lines of code include the Shape class and its Triangle child class. This code also includes a call to the getArea method, which exists in the Triangle class but not the Shape class. How can that line be improved by making Shape an abstract class with an abstract getArea method? QUESTION 15 Shape triangle = new Triangle(); double area = ((Triangle) triangle).getArea(); For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Save Answer
QUESTION 16 An interface is like a contract. How does this description relate to keeping code organized and secure within the subclasses of an interface? For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph Open Sans,sa... V P QUESTION 17 How does using a try-with-resources make file handling simpler and more secure? For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph V Open Sans,sa... V 10pt P QUESTION 18 10pt How does the File class adhere to the class-design guideline of cohesion? > !!! !!! < ||| !!! <l A Ix Ix
QUESTION 1 Indicate the correct term for each definition in the given blanks. The terms are worth 1 point each. ✓ Defaul
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am