Sun Certified Java Programmer MCQ Flashcards
7 cards from real SCJP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Sun Certified Java Programmer MCQ flashcards as text
What is the output of: System.out.println(1 + 2 + "3" + 4 + 5);
Answer: 3345
Left-to-right evaluation: 1+2=3, then 3+"3"="33", then "33"+4="334", then "334"+5="3345".
Which access modifier allows a member to be accessed only within its own package and by subclasses?
Answer: protected
The 'protected' modifier grants access within the same package and to subclasses in other packages.
What happens when you try to call a method on a null reference in Java?
Answer: NullPointerException is thrown
Calling any method on a null reference at runtime throws a NullPointerException.
Which of the following correctly declares a two-dimensional array in Java?
Answer: int[][] arr = new int[2][3];
The correct syntax is 'int[][] arr = new int[2][3];' which declares and allocates a 2x3 array.
What is the default value of an instance variable of type boolean in Java?
Answer: false
Instance variables of type boolean default to false if not explicitly initialized.
Which keyword is used to prevent method overriding in Java?
Answer: final
Declaring a method as 'final' prevents it from being overridden in any subclass.
What will be the result of 7 % 3 in Java?
Answer: 1
The modulo operator returns the remainder: 7 divided by 3 is 2 with remainder 1.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy