Basic Java Programming Quiz 2
Tests knowledge of core Java programming concepts including access modifiers, abstract classes, interfaces, threading, synchronization, and serialization.
Questions
Methods that are marked protected can be called in any subclass of that class.
- True
- False
An abstract class can have non-abstract methods.
- True
- False
Java keywords are written in lowercase as well as uppercase.
- True
- False
What is an instanceof
- A methods in object
- An operator and keyword
Primitive datatypes are allocated on a stack.
- True
- False
Can you compare a boolean to an integer?
- Yes
- No
If class A implements an interface does it need to implement all methods of that interface?
- Yes, always.
- No, not when A is abstract
Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?
- Compiler error
- Runtime Exception
- True
- False
The methods wait(), notify() and notifyAll() in Object need to be called from synchronized pieces of code.
- True
- False
Inner classes can be defined within methods.
- True
- False
Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution.
- True
- False
The default statement of a switch is always executed.
- True
- False
How can you prevent a member variable from becoming serialized?
- By marking it private
- By marking it volatile
- By marking it transient
- You can not.
The default statement of a switch is always executed.
- True
- False