Basic Java Programming Quiz 2

Tests knowledge of core Java programming concepts including access modifiers, abstract classes, interfaces, threading, synchronization, and serialization.

14 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Methods that are marked protected can be called in any subclass of that class.

  1. True
  2. False
Question 2 Multiple Choice (Single Answer)

An abstract class can have non-abstract methods.

  1. True
  2. False
Question 3 Multiple Choice (Single Answer)

Java keywords are written in lowercase as well as uppercase.

  1. True
  2. False
Question 4 Multiple Choice (Single Answer)

What is an instanceof

  1. A methods in object
  2. An operator and keyword
Question 5 Multiple Choice (Single Answer)

Primitive datatypes are allocated on a stack.

  1. True
  2. False
Question 6 Multiple Choice (Single Answer)

Can you compare a boolean to an integer?

  1. Yes
  2. No
Question 7 Multiple Choice (Single Answer)

If class A implements an interface does it need to implement all methods of that interface?

  1. Yes, always.
  2. No, not when A is abstract
Question 8 Multiple Choice (Single Answer)

Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?

  1. Compiler error
  2. Runtime Exception
  3. True
  4. False
Question 9 Multiple Choice (Single Answer)

The methods wait(), notify() and notifyAll() in Object need to be called from synchronized pieces of code.

  1. True
  2. False
Question 10 Multiple Choice (Single Answer)

Inner classes can be defined within methods.

  1. True
  2. False
Question 11 Multiple Choice (Single Answer)

Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution.

  1. True
  2. False
Question 12 Multiple Choice (Single Answer)

The default statement of a switch is always executed.

  1. True
  2. False
Question 13 Multiple Choice (Single Answer)

How can you prevent a member variable from becoming serialized?

  1. By marking it private
  2. By marking it volatile
  3. By marking it transient
  4. You can not.
Question 14 Multiple Choice (Single Answer)

The default statement of a switch is always executed.

  1. True
  2. False