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(); }
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
