1. What is Java?
A) A low-level programming language
B) A high-level, class-based, object-oriented programming language
C) A scripting language used for web development
D) A platform for developing mobile applications
Answer: B) A high-level, class-based, object-oriented programming language
2. What is the difference between JDK and JRE?
A) JDK is required to run Java programs, JRE is used for compiling Java code.
B) JDK is a software development kit, JRE is a runtime environment for
running Java applications.
C) JDK is used for mobile development, JRE is for desktop applications.
D) JDK is an updated version of JRE.
Answer: B) JDK is a software development kit, JRE is a runtime environment
for running Java applications.
3. What is the JVM (Java Virtual Machine)?
A) It is a hardware device that executes Java bytecode.
B) It is a software platform that allows Java programs to run on any machine.
C) It is a compiler that translates Java code into machine code.
D) It is a type of database management system.
Answer: B) It is a software platform that allows Java programs to run on any
machine.
4. What is the difference between == and .equals() in Java?
A) == compares the actual contents of two objects, while .equals() compares
memory references.
B) == compares memory references, while .equals() compares the actual
contents of two objects.
C) Both == and .equals() are used to compare memory references.
D) == is used only for primitive types, while .equals() is used for objects.
Answer: B) == compares memory references, while .equals() compares the
actual contents of two objects.
5. What are the main features of Java?
A) Single-threaded, platform-dependent, and functional.
B) Object-oriented, platform-independent, and robust.
C) Procedural, platform-dependent, and slow.
D) High-level, unstructured, and optimized for system programming.
Answer: B) Object-oriented, platform-independent, and robust.
6. What is inheritance in Java?
A) The process of creating a new object from an existing one.
B) The mechanism where one class inherits the fields and methods of
another class.
C) The method of preventing access to a class's variables.
D) A technique used to hide the implementation details of a class.
Answer: B) The mechanism where one class inherits the fields and methods
of another class.
7. What is polymorphism in Java?
A) The ability to write Java code that can run on multiple devices.
B) The concept of defining methods in a class that have the same name but
different implementations.
C) The ability of one method to return multiple types of values.
D) The ability to have multiple classes with the same name.
Answer: B) The concept of defining methods in a class that have the same
name but different implementations.
8. What is an interface in Java?
A) A class that implements another class.
B) A type that defines a contract for methods, but does not provide their
implementation.
C) A method that handles user input.
D) A type that defines data members for use in other classes.
Answer: B) A type that defines a contract for methods, but does not provide
their implementation.
9. What is the difference between ArrayList and LinkedList in Java?
A) ArrayList is backed by a dynamic array, while LinkedList is backed by a
linked list.
B) ArrayList allows faster insertion at the beginning, while LinkedList allows
faster access by index.
C) ArrayList is always faster than LinkedList for all operations.
D) ArrayList and LinkedList are the same and can be used interchangeably.
Answer: A) ArrayList is backed by a dynamic array, while LinkedList is backed
by a linked list.
10. What are Java's access modifiers?
A) public, protected, private, final
B) public, private, protected, default
C) static, final, volatile, transient
D) private, package, protected, global
Answer: B) public, private, protected, default