GSSP-Java

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?

  1. Exception
  2. An exception is thrown at runtime.
  3. Compilation fails.
  4. Arithmetic Exception

Question 52

Which directory in JAR files is used to store package and extension configuration data?

  1. META-INF
  2. GAMMA-INF
  3. ZIP-INF
  4. 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?

  1. It cannot be determined.
  2. 1
  3. 2
  4. 0

Question 54

Which of the following are valid thread state transitions? Each correct answer represents a complete solution. Choose all that apply.

  1. From running to ready.
  2. From ready to waiting.
  3. From running to waiting.
  4. From waiting to ready.
  5. From ready to running.
  6. 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"?

  1. Car.Engine e = c.new Engine();
  2. Engine e = c. new Engine();
  3. c.Engine e = Car.new Engine();
  4. Car.Engine e = Car.new Engine();