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

Given the following code: public class Test{ public static void throwEx(){ Syste

ID: 3714397 • Letter: G

Question

Given the following code:

public class Test{

public static void throwEx(){

System.out.println(“throwex”);

throw new RuntimeException();

}

public static void main(String[] args){

try{ System.out.print(“try”);

throwEx();

} catch (Exception e) {

System.out.print(“catch”);

} finally { System.out.println(“finally”);

} System.out.println(“done”);

} }

Choose one result:

a. Compilation fails

b. try throwEx catch

c. try throwEx RuntimeException

d. try throwEx catch finally done

e. try throwEx RuntimeException catch finally done

Part B:

Then answer the following

Which one statement is true”

a. All objects that are eligible for garbage collection will be removed from the heap by the garbage collector.

b. Objects with more than one reference will never be garbage collected.

c. Objects from a class with the finalize() method overridden will never be garbage collected.

d. Objects instantiated within method local inner classes are placed in the garbage collectible heap.

e. Once an overridden finalize() method is invoded, there is no way to make that object ineligible for garbage collection.


Part C:
What is the result?

int x = 12 & 13;

int y = x ^ 6;

System.out.println(y);

b. 12

c. 14

d. 13

e. 11

f. 0

g. 10

Part D:

Given the following:

1. import java.io.*;

2. public class Test {

3. public static void main(String args[]){

4. FileInputStream in = null;

5. try {

6. in = new FileInputStream(“hello.txt”);

7. int x = in.read();

8. }

9. catch (IOException ioe) {

10. System.out.print(“IO error”);

11. }

12. finally {

13. in.close();

14. }

15. }

And given that all methods in the FileInputStream throw an IOException, which of these is true?

a. It compiles correctly.

b. The program fails to compile due to an error on line: 4

c. The program fails to compile due to an error on line: 6

d. The program fails to compile due to an error on line: 9

e. The program fails to compile due to an error on line: 13

Explanation / Answer

Answer:- //if you have any query then comment below.please rate the answer

Part A)  d. try throwEx catch finally done

Part B)  d. Objects instantiated within method local inner classes are placed in the garbage collectible heap.?

Part C) 10

Part D)  e. The program fails to compile due to an error on line: 13 ?

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote