Core Java Online Test Questions and Answers - 3

21. Which of the following is true for Garbage collector thread?

a. GC is a Non daemon thread
b. GC is a Daemon thread
c. GC is a thread with dead state
d. None of the above

Answer: b. GC is a Daemon thread


22. A thread enters into a Dead State when a thread terminates its processing.

a. True  
b. False

Answer: a. True


23. Which keyword when applied on a method allow one thread at a time into a method thus allowing to protect data from being corrupted by simultaneous modifications from different threads?

a. synchronized
b. volatile
c. transient
d. native

Answer: a. synchronized



24. Name the Collection interface that is used to represent elements in a sequence.

a. Collection
b. Set
c. List  
d. Map

Answer: c. List


25. Is HashTable a sub class of Dictionary?

a. Yes
b. No

Answer: a. Yes


26. Which of the following are true about interfaces?

a. All methods declared inside Java Interfaces are implicitly public and abstract
b. Variables declared in interfaces are implicitly public, static, and final.
c. An interface can extend any number of interfaces.
d. Methods declared in interfaces are implicitly private.

A) a, b, c
B) c, d
C) b, d
D) b, c

Answer: A) a, b, c


27. Which class enables you to read Java objects from an InputStream?

a. Reader
b. File
c. ObjectReader
d. ObjectInputStream

Answer: d. ObjectInputStream


28. The process of creating object from sequence of bytes is called

a. serialization
b. deserialization
c. Threading
d. Marshalling

Answer: b. deserialization


29. Which is best way to say a method is complete and can't be overridden?

a. final
b. static
c. we cant prevent
d. by default it provides

Answer: a. final


30. The default constructor initializes the instance variables declared in the class.

a. True
b. False

Answer: a. True