GSSP-Java practice questions, page 11 of 11, with answer review and explanations.
Question 51
Mark works as an Application Developer for XYZ Solutions Inc. He writes the following code. public class TestDemo{public static void main(String[] args){ {try{int x =0;int d= 5/x;}catch(Exception ex){System.out.println("Exception");} catch(ArithmeticException ae){System.out.println("Arithmetic Exception");}}} What is the result when Mark tries to compile and execute the code?
Exception
An exception is thrown at runtime.
Compilation fails.
Arithmetic Exception
Question 52
Which directory in JAR files is used to store package and extension configuration data?
META-INF
GAMMA-INF
ZIP-INF
TAR-INF
Question 53
Mark works as a Programmer for InfoTech Inc. He creates a program that uses the following code. 1. class Book 2. { 3. Short f1= 15; 4. Book GetDetails(Book b1) 5. { 6. b1=null; 7. return b1; 8. } 9. public static void main(String args[]) 10. { 11. Book b1 = new Book(); 12. Book b2 = new Book(); 13. Book b3 = b1.GetDetails(b2); 14. b1=null; 15. //code 16. } 17. } How many objects will be eligible for garbage collection when line 15 is reached?
It cannot be determined.
1
2
0
Question 54
Which of the following are valid thread state transitions? Each correct answer represents a complete solution. Choose all that apply.
From running to ready.
From ready to waiting.
From running to waiting.
From waiting to ready.
From ready to running.
From waiting to running.
Question 55
You work as a Programmer for InfoTech Inc. You write the following code. 1. public class InnerDemo{ 2. public static void main(String[] args) { 3. Car c = new Car(); 4. // insert code here 5. e.test(); 6. } 7. } 8. class Car{ 9. class Engine{ 10. void test() {System.out.println("test"); } 11. } 12. } Which of the following options should you add to line 4 so that the code compiles and produces the output "test"?