Java Programming Quiz
100%

Java Programming Quiz

Test your Java programming knowledge with these multiple-choice questions. This quiz covers Java basics, variables, operators, conditions, loops, arrays, OOP, exception handling, collections, and file handling.

Total Questions: 20
Marks: 1 mark per question
Maximum Score: 20
Select one answer for each question and click Submit Quiz to see your result.
Question 1: Java Basics

Which keyword is used to create a class in Java?

Question 2: Variables

Which data type is commonly used to store a whole number in Java?

Question 3: Output

What is the output of this code?

System.out.println(10 + 20);
Question 4: Operators

Which operator checks whether two primitive values are equal?

Question 5: Conditional Statements

Which statement executes code when a condition is true?

Question 6: Loops

How many times does this loop execute?

for (int i = 1; i <= 3; i++) {
    System.out.println(i);
}
Question 7: Arrays

What is the index of the first element in a Java array?

Question 8: Strings

Which method returns the number of characters in a String?

Question 9: Methods

Which keyword sends a value back from a method?

Question 10: Object-Oriented Programming

Which keyword is used to create an object in Java?

Question 11: Constructors

What is the name of a constructor in Java?

Question 12: Inheritance

Which keyword is used to inherit a class in Java?

Question 13: Encapsulation

Which access modifier restricts direct access to a member to its declaring class?

Question 14: Interfaces

Which keyword declares that a class implements an interface?

Question 15: Exception Handling

Which block is commonly used to handle an exception after a try block?

Question 16: Collections

Which Java collection allows duplicate elements and maintains their sequence?

Question 17: Maps

Which collection stores data as key-value pairs?

Question 18: File Handling

Which package contains many Java file I/O classes such as File and FileReader?

Question 19: Multithreading

Which method contains the task executed by a typical Java Thread?

Question 20: JDBC

What is JDBC primarily used for?