scjp MCQ Question and Answer
scjp MCQ Question and Answer
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;
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;
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
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
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
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
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.
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.
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)
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.