scjp MCQ Question and Answer
scjp MCQ Question and Answer
31. Read the following code carefully.
- Will cause a compilation error
- Runtime Execption - NullPointerException in the 2nd line of the main method.
- Will compile successfully and print nullnull on the screen.
- Will compile successfully and print an empty line on the screen.
32. Read the code below carefully
- An attempt to compile will cause a compilation error. Static methods cannot be synchronized.
- Compilation will be successfull. The Object instantiated will have a lock which has to be gained by Threads calling any of the two methods.
- 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
- 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
33. Class fields with the following modifiers will not be serialized
- private
- static
- transient
- protected
34. 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
- The above expression will cause a '0' appear on the command line.
- Will throw a NullPointerException
- Will a blank line to appear.
35. A demon Thread group
- has only demon threads.
- can have non demon threads
- does not exist after all non demon threads in the group have finished executing.
- does not exist after all the threads in the group have finished executing.
36. 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.
- TRUE
- FALSE
37. The no-argument constructor provided by the compiler when no constructor is explicitly provided in the code
- is always public
- is always "friendly"
- always defaults to the access modifier provided for the class.
- depends on the compilation options of javac
38. Which of the following is the direct base class of java.awt.AWTEvent.
- java.lang.Object.
- java.util.EventObect
39. Interface methods can be declared with the following modifiers
- public
- none (i.e., no access modifier).
- private.
- static
40. Which of the following are true about the class defined inside an interface
- it is not possible in the java Laungage
- The class is always public
- The class is always static
- the class methods cannot call the methods declared in the interface.