scjp MCQ Questions and Answers

Practice Mode
Showing 10 of 52 questions
Q31
Read the following code carefully.
  • A Will cause a compilation error
  • B Runtime Execption - NullPointerException in the 2nd line of the main method.
  • C Will compile successfully and print nullnull on the screen.
  • D Will compile successfully and print an empty line on the screen.
Answer: Option C
Q32
Read the code below carefully
  • A An attempt to compile will cause a compilation error. Static methods cannot be synchronized.
  • B Compilation will be successfull. The Object instantiated will have a lock which has to be gained by Threads calling any of the two methods.
  • C Compilation will be successfull. There will exist a Class wide lock which will have to be gained by the Thread calling method1 and an instance lock for each instance which will have to be gained by the Thread making a call to method2 on the Object instanc
  • D Compilation will be successfull. There will exist a Class wide lock which will have to be gained by the Thread calling method1 and an instance lock for each instance which will have to be gained by the Thread making a call to method2 on the Object instanc
Answer: Option C
Q33
Class fields with the following modifiers will not be serialized
  • A private
  • B static
  • C transient
  • D protected
Answer: Option C
Q34
Assume that Cat is a class and String[] args is the argument passed to the public static void main(String args[]) method of the class. The class is executed with the following command line string
  • A The above expression will cause a '0' appear on the command line.
  • B Will throw a NullPointerException
  • C Will a blank line to appear.
Answer: Option A
Q35
A demon Thread group
  • A has only demon threads.
  • B can have non demon threads
  • C does not exist after all non demon threads in the group have finished executing.
  • D does not exist after all the threads in the group have finished executing.
Answer: Option
Q36
Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
  • A TRUE
  • B FALSE
Answer: Option B
Q37
The no-argument constructor provided by the compiler when no constructor is explicitly provided in the code
  • A is always public
  • B is always "friendly"
  • C always defaults to the access modifier provided for the class.
  • D depends on the compilation options of javac
Answer: Option C
Q38
Which of the following is the direct base class of java.awt.AWTEvent.
  • A java.lang.Object.
  • B java.util.EventObect
Answer: Option B
Q39
Interface methods can be declared with the following modifiers
  • A public
  • B none (i.e., no access modifier).
  • C private.
  • D static
Answer: Option
Q40
Which of the following are true about the class defined inside an interface
  • A it is not possible in the java Laungage
  • B The class is always public
  • C The class is always static
  • D the class methods cannot call the methods declared in the interface.
Answer: Option
Questions and Answers for Competitive Exams Various Entrance Test