Java Keywords

Tests knowledge of Java reserved words and their specific usage in programming

11 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which Java keyword should be used with a data member to make it non-serializable?

  1. private
  2. public
  3. transient
  4. unserialize
  5. none of the above
Question 2 Multiple Choice (Single Answer)

Which of the following keywords is used to implement inheritance in Java?

  1. inheritance
  2. inherit
  3. extend
  4. extends
Question 3 Multiple Choice (Single Answer)

Which of the following statements is correct?
A. super keyword is used to access the constructor of superclass from subclass constructor.
B. super keyword is used to access the variable of superclass from the subclass.

  1. Only A
  2. Only B
  3. Both A and B
  4. Neither A nor B
Question 4 Multiple Choice (Single Answer)

Interface can be implemented using the ___________ keyword.

  1. implement
  2. implements
  3. extend
  4. extends
Question 5 Multiple Choice (Single Answer)

Which of the following keywords should be used to make a class level variable?

  1. final
  2. static
  3. private
  4. classlevel
  5. public
Question 6 Multiple Choice (Single Answer)

All the variables must be __________ and initialized in the interface.

  1. static
  2. finalize
  3. final
  4. protected
Question 7 Multiple Choice (Single Answer)

Which of the following is not a keyword of Java?

  1. static
  2. final
  3. protected
  4. virtual
Question 8 Multiple Choice (Single Answer)

The protected access specifier works as ________ for outside world, but works as ________ for derived classes in Java.

  1. private and public
  2. public and private
  3. private and private
  4. public and public
Question 9 Multiple Choice (Single Answer)

If the first statement of a constructor has the form ________, then the constructor calls another constructor of the same class.

  1. static
  2. this(parameter list)
  3. this
  4. static(parameter list)
Question 10 Multiple Choice (Single Answer)

The protected access specifier is very useful in ___________ inheritance.

  1. simple
  2. multiple
  3. multilevel
  4. hierarchical
Question 11 Multiple Choice (Single Answer)

Which of the following statements regarding 'finally' block in Java is false?

  1. Before the termination of the program, JVM executes the 'finally' block (if any).
  2. The 'finally' block can be used for writing the cleanup code.
  3. The 'finally' block must be followed by try or catch block.
  4. There can be multiple 'finally' blocks for a try block.
  5. The 'finally' block is not executed if the program exists.