scjp MCQ Questions and Answers

Practice Mode
Showing 10 of 52 questions
Q21
Read the following code excerpt carefully
  • A A.java cannot be compiled. Duplicate defination of inner class B.
  • B A.java compiles without any error. An attempt to run C as an application will cause runtime linkage error. Duplicate definations of inner class B are found
  • C Only one class file corresponding to the inner class B is created in the file system.
  • D Two class files corresponding to both inner classes (B) is created in the file system.
Answer: Option
Q22
Attempting to compile and run the code will cause
  • A Compiler error - abstract classes cannot have constructors.
  • B Compiler error - the method AbstractClass does not have a valid return type.
  • C Compiler error - the class cannot be declared as abstract as it does not have any unimplemented methods.
  • D No compiler error - the class is practically not an abstract class and can be instantiated.
Answer: Option A
Q23
Read the following piece of code carefully.
  • A It can be achived by placing the call to the superclass with a super keyword , which is placed in a try block with a catch block to handle the IOException thrown by the super class.
  • B It can be achived by avoiding explicit calls to the base class constructor.
  • C It cannot be done in the Java Laungage with the above definition of the base class.
Answer: Option C
Q24
Read the following piece of code carefully
  • A will cause a compiler error. The non-abstract classes cannot be extended to the abstract classes.
  • B will cause a compiler error. The abstract classes cannot have constructors defined.
  • C will not cause any compiler error. The lines "Message 1..." and "Message 3 ... " are printed on the screen.
  • D will not cause any compiler error. The lines "Message 1..." and "Message 2...." and Message 3...." are printed on the screen.
Answer: Option D
Q25
Read the following piece of code carefully.
  • A The class A can be referenced outside the package in which it is defined.
  • B The class A cannot be instantiated outside the package in which it is defined.
  • C The class A cannot be extended outside the package in which it is defined.
  • D The class A can be referenced, instantiated or extended anywhere.
Answer: Option
Q26
If a Runtime Exception is thrown in the finalize method
  • A The running application crashes
  • B The exception is simply ignored and the object is garbage collected.
  • C The exception is simply ignored, but the object is not garbage collected.
  • D The Exception causes the JVM to crash.
Answer: Option B
Q27
The factory class java.util.Collections
  • A is public
  • B implements the java.util.Collection interface.
Answer: Option A
Q28
what does the following expression return? (0.0 == -0.0)
  • A TRUE
  • B FALSE
Answer: Option A
Q29
What does the following expression print on the screen? System.out.println(Math.min(Float.NaN, Float.POSITIVE_INFINITY));
  • A NaN
  • B Infinity
  • C The expression throws a runtime exception - NaN is an illegal argument.
Answer: Option B
Q30
What does the following expression return Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);
  • A Float.POSITIVE_INFINITY
  • B Double.POSITIVE_INFINITY
  • C runtime Exception
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test