In: Computer Science
A brief explanation is needed for these true/false questions.
a) A method that contains a try-catch-finally structure may also have a “throws” declaration.
b) An arithmetic exception such as division by zero can be avoided by careful programming while an I/O exception such as file not found may occur regardless of the precautions taken by the programmer.
c) Lets assume that you create an object x of the Object class. You can assign any object (objects of other classes) to the object x directly (without explicit type casting).
d) If bounded parameters are employed, this means of restricting the types that can be used as generic type arguments.
e) We can create an object of a class which is extended from an abstract class without implementing its abstract methods, if we are not going to use these abstract methods.
f) Generic type information is available to the JVM at runtime.
Please upvote if you are ablr to understand this and if there is any query do mention it in the comment section.
a). This statement is false. throws keyword is used to throw a custom exceptions made by user whereas try catch finally block is used to handle the exceptions.
b). This statement is true. As a division by 0 can be avoided by making corrections in the code but an if there is a file not found error then the file has to be created manually before writitng the code.
c). This statement is true. As the object needs to be casted only if the object has to be converted into some type.
d). This statement is true. As a method which wants to accept parameters of a particular type.
e). This statement is false. As the abstract methods has to be implemented. The purpose of abstract methods is to be used in different classes but it is only declared in the abstract class.
f). This statement is false. As the generic type information is not available to the JVM at the run time but at the compile time.