scjp MCQ Questions and Answers

Take Exam

The SCJP MCQ questions with answers are designed to help learners strengthen their understanding of Java programming concepts. These programming questions and answers cover key areas such as classes, inheritance, polymorphism, and exception handling. Practicing these MCQs enhances your coding logic and prepares you for certification exams like Sun Certified Java Programmer (SCJP) as well as placement tests conducted by companies like TCS, Infosys, and Wipro. Each question includes detailed explanations to help you grasp Java fundamentals effectively. Start practicing these Java MCQ questions with solutions to improve your performance in competitive exams and technical interviews.

scjp MCQ

Showing 10 of 52 questions

11. public class AQuestion

  • Compiler error complaining about access restriction of private variables of AQuestion
  • Compiler error complaining about forward referencing
  • No error - The output is 0;
  • No error - The output is 10;
Show Answer Report

12. Look at the code

  • Compiler error complaining about access restriction of private variables of AQuestion
  • Compiler error complaining about forward referencing
  • No error - The output is 0;
  • No error - The output is 10;
Show Answer Report

13. Read the code below carefully

  • A RuntimeException due to incompatable change in class Constants
  • An Error due to incompatable change in class Constants
  • The program terminates normally and "Hello" is printed on the system console
  • The program terminates normally and "Hello World!" is printed on the system console
Show Answer Report

14. Read the code below carefully

  • Not compile. Vector v is not initialized
  • Will compile and throw a RuntimeException
  • Will compile and not throw any Exception during runtime. V is initalized to null
Show Answer Report

15. An attempt to compile and call the someMethod of the above class at runtime will cause

  • A compilation error : v is not initialized in all constructors
  • A compilation error : v is not an instance variable
  • "true" is printed on the console
  • "false" is printed on the console
Show Answer Report

16. An attempt to compile the above code will cause

  • A compilation error : The final variable is not initialized in all the constructors.
  • A compilation error : The final instance variable is reassigned after initialization in the constructor
  • 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.
  • A compilation error : The final instance variable is not initialized in the declaration
Show Answer Report

17. Attempting to compile and run the above application will yield

  • A compilation error : Final variable being assigned to a non-final handle.
  • A compilation error : implicitly final localSB being reassigned
  • A Runtime Error : Attempted reassignment to a final handle (localSB)
  • No Errors during compilation and execution. An Empty line is printed on the console.
Show Answer Report

18. Attempting to compile and run the above application will yeild

  • A compilation error : Final variable being assigned to a non-final handle.
  • A compilation error : implicitly final localSB being reassigned
  • A Runtime Error : Attempted reassignment to a final handle (localSB)
  • No Errors during compilation and execution. An empty line is printed on the console.
Show Answer Report

19. Attempting to compile and run the above application will yeild

  • A compilation error : non final variable being assigned to a final handle.
  • No Errors during compilation and execution. "I am final...." is printed on the console
  • A compilation error : final localSB being reassigned
  • A Runtime Error : Attempted reassignment to a final handle (localSB)
Show Answer Report

20. Attemping to compile and execute the above Code

  • Compilation error : Inner class inside method cannot have static members or blocks
  • Compilation error : Inner classes cannot be delared inside constructors
  • No compilation error : At runtime Class B is not loaded
  • No compilation error : At runtime class B is loaded and the message "I am getting loaded" is printed on the console.
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test