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

UNYICSI CSC 330 Spring 2017 05/23/2017 Final Exam Code Examination: (4 x 5: 20 p

ID: 3843341 • Letter: U

Question

UNYICSI CSC 330 Spring 2017 05/23/2017 Final Exam Code Examination: (4 x 5: 20 points) (Java Code). The following 6 questions are based on Final Exam Handout Number 1 structure Class' an of the method. Notice that the code (String args) the following and the flow of the public void main comment. Answer line of code ends with a sequential number in a been questions following lines have 12. What's the value of total (defined on line 3) after the executed? Line 21 Line 26 13 Would it be accurate to describe the simplecalculator Class as an immutable Object Class? Explain 14. Which of the code lines 23 through 28 must be part of the try f)/catch0 block? Explain 15 After line 37 has been executed, the SimpleCalculator instance created on line 21 is up for garbage collection: O (a) True (b) False Explain:

Explanation / Answer

12)

Line 21 : the value of total =0.0;

Line 26 : the value of total =16.0;

13)

To make SimpleCalculator as immutable we have to declare the class as final.So that we cant create a sub class to the SimpleCalculator class.

We have to declare the instance variables of this class as final.So once after creating an instance to the SimpleCalculator class,we cannot change the values of the instance variables.

14)

Line 27 must be part of try,catch block .Because, There might be a chance of rising an Exception when we call a method div() on the SimpleCalculator class object.So to avoid the sudden termination of program if any Exception is raised while executing the program we have to place that line 27 inside try catch block.

15)

True,

Here the reference variable calc is not referring to anything after the line 37 is executed.So those references which are not pointing to anything are eligible for garbage collection before termination of the program.

______________Could you rte me well plz.Thank You