scjp MCQ Questions and Answers

Practice Mode
Showing 10 of 52 questions
Q11
public class AQuestion
  • A Compiler error complaining about access restriction of private variables of AQuestion
  • B Compiler error complaining about forward referencing
  • C No error - The output is 0;
  • D No error - The output is 10;
Answer: Option B
Q12
Look at the code
  • A Compiler error complaining about access restriction of private variables of AQuestion
  • B Compiler error complaining about forward referencing
  • C No error - The output is 0;
  • D No error - The output is 10;
Answer: Option B
Q13
Read the code below carefully
  • A A RuntimeException due to incompatable change in class Constants
  • B An Error due to incompatable change in class Constants
  • C The program terminates normally and "Hello" is printed on the system console
  • D The program terminates normally and "Hello World!" is printed on the system console
Answer: Option C
Q14
Read the code below carefully
  • A Not compile. Vector v is not initialized
  • B Will compile and throw a RuntimeException
  • C Will compile and not throw any Exception during runtime. V is initalized to null
Answer: Option A
Q15
An attempt to compile and call the someMethod of the above class at runtime will cause
  • A A compilation error : v is not initialized in all constructors
  • B A compilation error : v is not an instance variable
  • C "true" is printed on the console
  • D "false" is printed on the console
Answer: Option B
Q16
An attempt to compile the above code will cause
  • A A compilation error : The final variable is not initialized in all the constructors.
  • B A compilation error : The final instance variable is reassigned after initialization in the constructor
  • C No compilation error : But will cause a run time exception (NullPointerException) if someMethod is called on an instance that was created through the constructor with the integer argument.
  • D A compilation error : The final instance variable is not initialized in the declaration
Answer: Option A
Q17
Attempting to compile and run the above application will yield
  • A A compilation error : Final variable being assigned to a non-final handle.
  • B A compilation error : implicitly final localSB being reassigned
  • C A Runtime Error : Attempted reassignment to a final handle (localSB)
  • D No Errors during compilation and execution. An Empty line is printed on the console.
Answer: Option D
Q18
Attempting to compile and run the above application will yeild
  • A A compilation error : Final variable being assigned to a non-final handle.
  • B A compilation error : implicitly final localSB being reassigned
  • C A Runtime Error : Attempted reassignment to a final handle (localSB)
  • D No Errors during compilation and execution. An empty line is printed on the console.
Answer: Option D
Q19
Attempting to compile and run the above application will yeild
  • A A compilation error : non final variable being assigned to a final handle.
  • B No Errors during compilation and execution. "I am final...." is printed on the console
  • C A compilation error : final localSB being reassigned
  • D A Runtime Error : Attempted reassignment to a final handle (localSB)
Answer: Option C
Q20
Attemping to compile and execute the above Code
  • A Compilation error : Inner class inside method cannot have static members or blocks
  • B Compilation error : Inner classes cannot be delared inside constructors
  • C No compilation error : At runtime Class B is not loaded
  • D No compilation error : At runtime class B is loaded and the message "I am getting loaded" is printed on the console.
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test