GSSP-Java

GSSP-Java practice questions, page 4 of 11, with answer review and explanations.

Question 16

You have written the following code snippet. 1. public class Read { 2. protected int ReadText(int x) { return 0; } 3. } 4. class Text extends Read { 5. /*insert code here*/ 6. } Which of the following methods, inserted independently at line 5, will compile? Each correct answer represents a complete solution. Choose all that apply.

  1. private int ReadText(long x) { return 0; }
  2. protected long ReadText(int x, int y) { return 0; }
  3. protected long ReadText(long x) { return 0; }
  4. protected int ReadText(long x) { return 0; }
  5. private int ReadText(int x) { return 0; }
  6. public int ReadText(int x) { return 0; }
  7. protected long ReadText(int x) { return 0; }

Question 17

You work as a Software Developer for UcTech Inc. You create a session using the HttpSession interface. You want the attributes to be informed when the session is moved from one JVM to another and also when an attribute is added or removed from the session. Which of the following interfaces can you use to accomplish the task? Each correct answer represents a complete solution. Choose all that apply.

  1. HttpSessionBindingListener
  2. HttpSessionListener
  3. HttpSessionActivationListener
  4. HttpSessionAttributeListener

Question 18

Which of the following statements are true? Each correct answer represents a complete solution. Choose all that apply.

  1. An inner class cannot be defined as private.
  2. An inner class cannot be defined as protected.
  3. An inner class can be defined as private.
  4. An inner class can extend another class.

Question 19

You work as a programmer for PassGuide.Inc. You have a session object named session1 with an attribute named Attribute1, and an HttpSessionBindingEvent object binding1 bound to session1. Which of the following will be used to retrieve Attribute1? Each correct answer represents a complete solution. Choose all that apply.

  1. Object obj=binding1.getSession().getAttribute("Attribute1");
  2. Object obj=binding1.getAttribute("Attribute1");
  3. Long MyAttribute=session1.getAttribute("Attribute1");
  4. String str1=session1.getAttribute("Attribute1");
  5. Object obj=session1.getAttribute("Attribute1");

Question 20

Which of the following statements about a JAR file are true? Each correct answer represents a complete solution. Choose all that apply.

  1. It cannot be accessed through a class path, nor they can be used by java and javac.
  2. It is used to compress and archive data.
  3. It can be moved from one computer to another.
  4. It is created by using the jar command.