Java Quiz ( Beginner ) - All Questions
This beginner-level Java quiz is perfect for learners who are new to Java programming. It covers Java basics such as syntax, data types, variables, operators, control statements, OOP fundamentals, and core concepts commonly asked in entry-level exams and interviews.
Question 1: What is Java?
- An operating system
- A programming language
- A database
- A web browser
Explanation: Java is a high-level programming language.
Question 2: Who developed Java?
- Google
- Sun Microsystems
- Microsoft
- IBM
Explanation: Java was developed by Sun Microsystems.
Question 3: Which file extension is used for Java source files?
Explanation: Java source files use the .java extension.
Question 4: Which component executes Java bytecode?
Explanation: JVM executes Java bytecode.
Question 5: What does JDK stand for?
- Java Deployment Kit
- Java Development Kit
- Java Design Kit
- Java Debug Kit
Explanation: JDK stands for Java Development Kit.
Question 6: Which keyword is used to define a class in Java?
Explanation: The class keyword is used to define a class.
Question 7: Which method is the entry point of a Java program?
Explanation: main() is the entry point of a Java program.
Question 8: Which keyword is used to create an object?
Explanation: Objects are created using the new keyword.
Question 9: Which data type is used to store whole numbers?
Explanation: int stores whole numbers.
Question 10: Which data type stores true or false values?
Explanation: boolean stores true or false values.
Question 11: Which data type stores a single character?
Explanation: char stores a single character.
Question 12: Which keyword is used for inheritance?
- inherits
- extends
- implements
- super
Explanation: extends is used for class inheritance.
Question 13: Which concept allows code reuse?
- Encapsulation
- Inheritance
- Abstraction
- Compilation
Explanation: Inheritance allows code reuse.
Question 14: Which keyword is used to implement an interface?
- extends
- implements
- interface
- inherits
Explanation: implements is used to implement interfaces.
Question 15: Which loop executes at least once?
Explanation: do-while executes at least once.
Question 16: Which loop is best when number of iterations is known?
Explanation: for loop is best when iterations are known.
Question 17: Which statement is used for decision making?
Explanation: switch is used for decision making.
Question 18: Which keyword exits a loop immediately?
Explanation: break exits the loop.
Question 19: Which keyword skips the current loop iteration?
Explanation: continue skips the current iteration.
Question 20: Which operator checks equality?
Explanation: == checks equality.
Question 21: Which operator performs logical AND?
Explanation: && is logical AND.
Question 22: Which keyword refers to the current object?
Explanation: this refers to the current object.
Question 23: Which keyword refers to the parent class?
Explanation: super refers to the parent class.
Question 24: Which keyword prevents inheritance?
Explanation: final prevents inheritance.
Question 25: Which keyword prevents method overriding?
- abstract
- static
- final
- private
Explanation: final methods cannot be overridden.
Question 26: Which keyword is used to define constants?
- static
- const
- final
- immutable
Explanation: final is used to define constants.
Question 27: Which OOP concept hides internal details?
- Inheritance
- Encapsulation
- Polymorphism
- Compilation
Explanation: Encapsulation hides internal details.
Question 28: Which feature allows multiple methods with same name?
- Inheritance
- Overloading
- Overriding
- Encapsulation
Explanation: Overloading allows same method name.
Question 29: Which feature allows redefining parent methods?
- Overloading
- Overriding
- Encapsulation
- Abstraction
Explanation: Overriding redefines parent methods.
Question 30: Which keyword defines an abstract class?
- interface
- virtual
- abstract
- extends
Explanation: abstract defines an abstract class.
Question 31: Can we create an object of an abstract class?
- Yes
- No
- Only once
- Only in main
Explanation: Abstract classes cannot be instantiated.
Question 32: Which keyword defines an interface?
- class
- abstract
- interface
- implements
Explanation: interface keyword defines an interface.
Question 33: Which package is automatically imported?
- java.util
- java.io
- java.lang
- java.net
Explanation: java.lang is imported by default.
Question 34: Which class is the parent of all classes?
Explanation: Object is the root class.
Question 35: Which keyword is used to handle exceptions?
Explanation: catch handles exceptions.
Question 36: Which block always executes?
Explanation: finally always executes.
Question 37: Which keyword throws an exception explicitly?
Explanation: throw explicitly throws exceptions.
Question 38: Which keyword declares exceptions?
- throw
- throws
- catch
- exception
Explanation: throws declares exceptions.
Question 39: Which feature makes Java platform-independent?
Explanation: JVM enables platform independence.
Question 40: Which memory area stores objects?
- Stack
- Heap
- Method area
- Register
Explanation: Objects are stored in heap memory.
Question 41: Which memory area stores local variables?
- Heap
- Stack
- Method area
- Class loader
Explanation: Local variables are stored in stack.
Question 42: Which mechanism frees unused memory automatically?
- Destructor
- Garbage Collection
- Manual delete
- Heap cleanup
Explanation: Garbage Collection frees unused memory.
Question 43: Which method requests garbage collection?
- gc()
- finalize()
- System.gc()
- clean()
Explanation: System.gc() requests garbage collection.
Question 44: Which collection does not allow duplicates?
Explanation: Set does not allow duplicate values.
Question 45: Which collection allows duplicate elements?
Explanation: List allows duplicate elements.
Question 46: Which keyword is used to create immutable variables?
Explanation: final creates immutable variables.
Question 47: Which Java feature supports object-oriented programming?
- Pointers
- Classes and objects
- Macros
- Structures
Explanation: Java uses classes and objects.
Question 48: What is the main goal of learning Java?
- UI design
- Build scalable applications
- Database management
- Network setup
Explanation: Java is used to build scalable applications.