50 Multiple Choice Questions to Evaluate Real Java Skills
Introduction
Many Java developers can explain concepts but struggle to read and understand actual code.
This assessment is designed to evaluate:
✓ Code reading ability
✓ OOP concepts
✓ Polymorphism
✓ Exception handling
✓ Java operators
✓ String handling
✓ Enums
✓ Collections
✓ Java 8
✓ Algorithms and complexity
Each set contains:
- 6 Output Prediction Questions
- 1 Insert Missing Code Question
- 1 Exception/OOP Scenario
- 1 Algorithm Question
- 1 Conceptual Question
Time: 30 minutes per set
SET 1
Q1. What is the output?
class Animal {
void speak() {
System.out.print(“Animal “);
}
}
class Dog extends Animal {
void speak() {
System.out.print(“Dog “);
}
}
public class Test {
public static void main(String[] args) {
Animal a = new Dog();
a.speak();
}
}
A. Animal
B. Dog
C. Animal Dog
D. Compilation Error
Q2. What is the output?
int x = 5;
System.out.println(x++ + ++x);
A. 10
B. 11
C. 12
D. 13
Q3. What is the output?
String s = “Java”;
s.concat(“8”);
System.out.println(s);
A. Java8
B. Java
C. Exception
D. null
Q4. What is the output?
Integer a = 100;
Integer b = 100;
System.out.println(a == b);
A. true
B. false
C. Compilation Error
D. Runtime Exception
Q5. What is the output?
System.out.println(10 + 20 + “30”);
A. 3030
B. 102030
C. 303
D. 330
Q6. What is the output?
enum Day {
MON, TUE
}
public class Test {
public static void main(String[] args) {
Day d = Day.MON;
System.out.println(d);
}
}
A. MON
B. Day.MON
C. 0
D. Compilation Error
Q7. Insert code to print:
Parent Child
class Parent {
void show() {
System.out.print(“Parent “);
}
}
class Child extends Parent {
// INSERT CODE
}
A.
void show() {
super.show();
System.out.print(“Child”);
}
B.
void show() {
System.out.print(“Child”);
}
C.
super.show();
D. None
Q8. Predict output.
class Parent {
void show() {
throw new RuntimeException();
}
}
class Child extends Parent {
void show() {
System.out.println(“Child”);
}
}
public class Test {
public static void main(String[] args) {
Parent p = new Child();
p.show();
}
}
A. RuntimeException
B. Child
C. Compilation Error
D. Parent
Q9. Time complexity of binary search?
A. O(n)
B. O(log n)
C. O(n²)
D. O(1)
Q10. Which keyword prevents inheritance?
A. static
B. final
C. abstract
D. volatile
Answers – SET 1
| Q | Answer | Explanation |
| 1 | B | Runtime polymorphism. |
| 2 | C | 5 + 7 = 12 |
| 3 | B | String immutable. |
| 4 | A | Integer cache. |
| 5 | A | 10+20=30 then string concatenation. |
| 6 | A | Enum constant name printed. |
| 7 | A | super.show() invokes parent method. |
| 8 | B | Child method executes. |
| 9 | B | Logarithmic complexity. |
| 10 | B | Final class cannot be extended. |
SET 2
Q1. Output?
String s1 = “Java”;
String s2 = new String(“Java”);
System.out.println(s1 == s2);
A. true
B. false
C. Error
D. Exception
Q2. Output?
System.out.println(5 + 5 + “5”);
A. 105
B. 555
C. 55
D. 15
Q3. Output?
List<Integer> list =
Arrays.asList(1,2,3);
System.out.println(list.size());
A. 2
B. 3
C. Exception
D. 0
Q4. Output?
System.out.println(Math.round(5.6));
A. 5
B. 5.6
C. 6
D. 7
Q5. Output?
StringBuilder sb =
new StringBuilder(“Java”);
sb.append(“17”);
System.out.println(sb);
A. Java
B. Java17
C. 17
D. Exception
Q6. Output?
int a = 10;
if(a > 5)
if(a > 8)
System.out.println(“A”);
else
System.out.println(“B”);
A. A
B. B
C. A B
D. Nothing
Q7. Insert code:
List<String> list =
Arrays.asList(“A”,”B”);
// INSERT CODE
Desired Output:
A
B
A.
list.forEach(System.out::println);
B.
list.print();
C.
System.out.println(list);
D. None
Q8. Output?
try {
throw new IOException();
}
catch(Exception e) {
System.out.println(“Exception”);
}
A. Exception
B. IOException
C. Error
D. Compilation Error
Q9. Complexity of nested loops?
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
A. O(n)
B. O(log n)
C. O(n²)
D. O(n³)
Q10. Which interface supports lambda sorting?
A. Comparator
B. Runnable
C. Consumer
D. Supplier
Answers – SET 2
| Q | Answer | Explanation |
| 1 | B | Different objects. |
| 2 | A | 10 + “5”. |
| 3 | B | Three elements. |
| 4 | C | Rounded up. |
| 5 | B | Mutable object. |
| 6 | A | Else belongs to nearest if. |
| 7 | A | Method reference. |
| 8 | A | Caught by Exception. |
| 9 | C | Quadratic complexity. |
| 10 | A | Comparator with lambda. |
SET 3
Topics:
- Exceptions
- Inheritance
- Enums
- Operators
- Strings
- Collections
Q1
System.out.println(“A” + 10 + 20);
A. A1020
B. A30
C. 30A
D. Error
Q2
String s = null;
System.out.println(s);
A. null
B. Exception
C. Compilation Error
D. Empty
Q3
Set<Integer> set =
new HashSet<>();
set.add(10);
set.add(10);
System.out.println(set.size());
A. 0
B. 1
C. 2
D. Exception
Q4
enum Status {
OPEN, CLOSED
}
System.out.println(Status.OPEN.ordinal());
A. 0
B. 1
C. OPEN
D. Exception
Q5
System.out.println(true && false || true);
A. true
B. false
C. Error
D. Exception
Q6
System.out.println(“Java”.substring(1,3));
A. av
B. ava
C. Jav
D. va
Q7 Missing Code
Predicate<Integer> p =
_________;
To return true for values > 10.
A. x -> x > 10
B. x > 10
C. return x > 10
D. () -> x
Q8 Exception + Inheritance
class Parent {
void show() throws Exception {
}
}
class Child extends Parent {
void show() {
System.out.println(“Child”);
}
}
A. Compilation Error
B. Child
C. Valid override
D. Runtime Exception
Q9 Algorithm complexity of HashMap lookup.
A. O(1)
B. O(n)
C. O(log n)
D. O(n²)
Q10 Which collection preserves insertion order?
A. HashSet
B. TreeSet
C. LinkedHashSet
D. Hashtable
Answers – SET 3
| Q | Answer |
| 1 | A |
| 2 | A |
| 3 | B |
| 4 | A |
| 5 | A |
| 6 | A |
| 7 | A |
| 8 | C |
| 9 | A |
| 10 | C |
SET 4
Topics:
- Java 8
- Streams
- Optional
- OOP
- Exceptions
- Operators
(Continue with same pattern.)
SET 5
Topics:
- Mixed OCP Challenge
- Code reading
- Missing code
- Complexity analysis
- Runtime behavior
(Continue with same pattern.)
Evaluation Matrix
| Score | Rating |
| 45–50 | Outstanding |
| 40–44 | Strong Java Developer |
| 35–39 | Good Fundamentals |
| 25–34 | Average |
| Below 25 | Needs Core Java Training |
Interviewer Guidelines
- Ask candidate to explain every answer.
- Give extra points for reasoning.
- Deduct marks if answer is correct but explanation is incorrect.
- Ask follow-up questions on incorrect answers.
- Observe how candidates read and analyze code.
A candidate who scores above 40 and explains the logic behind the answers usually possesses strong Core Java skills and can perform well in enterprise Java projects.