scjp MCQ Question and Answer

scjp MCQ Question and Answer
21. Read the following code excerpt carefully
  • A.java cannot be compiled. Duplicate defination of inner class 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
  • Only one class file corresponding to the inner class B is created in the file system.
  • Two class files corresponding to both inner classes (B) is created in the file system.
Show Answer
22. Attempting to compile and run the code will cause
  • Compiler error - abstract classes cannot have constructors.
  • Compiler error - the method AbstractClass does not have a valid return type.
  • Compiler error - the class cannot be declared as abstract as it does not have any unimplemented methods.
  • No compiler error - the class is practically not an abstract class and can be instantiated.
Show Answer
23. Read the following piece of code carefully.
  • 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.
  • It can be achived by avoiding explicit calls to the base class constructor.
  • It cannot be done in the Java Laungage with the above definition of the base class.
Show Answer
24. Read the following piece of code carefully
  • will cause a compiler error. The non-abstract classes cannot be extended to the abstract classes.
  • will cause a compiler error. The abstract classes cannot have constructors defined.
  • will not cause any compiler error. The lines "Message 1..." and "Message 3 ... " are printed on the screen.
  • will not cause any compiler error. The lines "Message 1..." and "Message 2...." and Message 3...." are printed on the screen.
Show Answer
25. Read the following piece of code carefully.
  • The class A can be referenced outside the package in which it is defined.
  • The class A cannot be instantiated outside the package in which it is defined.
  • The class A cannot be extended outside the package in which it is defined.
  • The class A can be referenced, instantiated or extended anywhere.
Show Answer
26. If a Runtime Exception is thrown in the finalize method
  • The running application crashes
  • The exception is simply ignored and the object is garbage collected.
  • The exception is simply ignored, but the object is not garbage collected.
  • The Exception causes the JVM to crash.
Show Answer
27. The factory class java.util.Collections
  • is public
  • implements the java.util.Collection interface.
Show Answer
28. what does the following expression return? (0.0 == -0.0)
  • TRUE
  • FALSE
Show Answer
29. What does the following expression print on the screen? System.out.println(Math.min(Float.NaN, Float.POSITIVE_INFINITY));
  • NaN
  • Infinity
  • The expression throws a runtime exception - NaN is an illegal argument.
Show Answer
30. What does the following expression return Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);
  • Float.POSITIVE_INFINITY
  • Double.POSITIVE_INFINITY
  • runtime Exception
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test