Alien head

Basic Java Programming Quiz 2

Description: Basic Java Programming Quiz 2
Number of Questions: 13
Created by:
Tags: java

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

  1. True

  2. False

Answer: 1

An abstract class can have non-abstract methods.

  1. True

  2. False

Answer: 1

Java keywords are written in lowercase as well as uppercase.

  1. True

  2. False

Answer: 2

What is an instanceof

  1. A methods in object

  2. An operator and keyword

Answer: 2

Primitive datatypes are allocated on a stack.

  1. True

  2. False

Answer: 1

Can you compare a boolean to an integer?

  1. Yes

  2. No

Answer: 2

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

Answer: 2

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

Answer: 4

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

  1. True

  2. False

Answer: 1

Inner classes can be defined within methods.

  1. True

  2. False

Answer: 1

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

  1. True

  2. False

Answer: 1

The default statement of a switch is always executed.

  1. True

  2. False

Answer: 2

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.

Answer: 3
+ View questions