Core Java forms the fundamental foundation of the Java programming language, encompassing standard syntax, object-oriented programming paradigms, and essential APIs required for standalone and backend application development. It covers crucial runtime components like the Java Virtual Machine (JVM), memory management, exception handling, multithreading, and the Collections Framework. A strong grip on core Java concepts is vital for debugging applications efficiently, writing reusable code, and clearing technical interviews across software engineering roles.
Core Java MCQs
1 min read
Correct Answer: b) 4 bytes
Explanation:
In Java, the int data type is always 4 bytes (32 bits).
Correct Answer: c) Use of Pointers
Explanation:
Java does not support explicit pointers to ensure security and robustness.
Correct Answer: a) Java Virtual Machine
Explanation:
JVM stands for Java Virtual Machine, which executes Java bytecode.
Correct Answer: b) false
Explanation:
The default value of a boolean instance variable is false.
Correct Answer: b) java.lang.Object
Explanation:
The Object class is the root of the class hierarchy in Java.
Correct Answer: b) No never
Explanation:
Java does not support multiple inheritance with classes to avoid the diamond problem.
Correct Answer: c) final
Explanation:
The final keyword prevents a class from being subclassed.
Correct Answer: b) Block to initialize static variables
Explanation:
A static block executes once when the class is loaded, primarily to initialize static variables.
Correct Answer: c) None
Explanation:
Constructors do not have a return type, not even void.
Correct Answer: b) The current object instance
Explanation:
The this keyword refers to the current object in a method or constructor.
Correct Answer: b) To refer to the immediate parent class object
Explanation:
The super keyword is used to access methods, constructors, and variables of the parent class.
Correct Answer: b) Same name and parameters in parent and child class
Explanation:
Overriding happens when a subclass provides a specific implementation for a method defined in its superclass.
Correct Answer: a) Same name but different parameters in same class
Explanation:
Overloading occurs when multiple methods in the same class have the same name but different parameters.
Correct Answer: b) No
Explanation:
Final methods cannot be overridden by subclasses.
Correct Answer: b) Its value cannot be changed once initialized
Explanation:
A final variable acts as a constant and cannot be reassigned.
Correct Answer: b) transient
Explanation:
The transient keyword tells the JVM to ignore the field during serialization.
Correct Answer: a) volatile
Explanation:
The volatile keyword ensures that changes to a variable are always visible to other threads.
Correct Answer: b) Can be accessed by only one thread at a time
Explanation:
Synchronized methods prevent thread interference by enforcing mutual exclusion.
Correct Answer: b) public static void main(String[] args)
Explanation:
The JVM looks for exactly public static void main(String[] args) to start the program.
Correct Answer: d) public
Explanation:
Public members are accessible from anywhere in the application.
Correct Answer: d) package-private
Explanation:
No modifier means package-private, which limits access to classes within the same package.
Correct Answer: c) break
Explanation:
The break statement exits the current loop entirely.
Correct Answer: b) Skips the current iteration and proceeds to the next
Explanation:
The continue statement bypasses the remaining code in the current iteration and moves to the next loop evaluation.
Correct Answer: d) boolean
Explanation:
Switch statements do not support boolean values.
Correct Answer: b) do-while executes at least once
Explanation:
A do-while loop evaluates its condition after execution, ensuring it runs at least one time.
Correct Answer: b) To check whether an object belongs to a specific class
Explanation:
The instanceof operator tests whether an object is an instance of a specified type.
Correct Answer: a) == compares references, equals compares content
Explanation:
The == operator checks memory addresses, while equals() evaluates logical equivalence.
Correct Answer: b) StringBuffer
Explanation:
StringBuffer is synchronized and thread-safe, unlike StringBuilder.
Correct Answer: b) A new String object is created
Explanation:
Strings are immutable in Java; modifying them creates a new object.
Correct Answer: b) Storage area in heap memory for unique string literals
Explanation:
The String Pool optimizes memory by storing one copy of each unique string literal.
Correct Answer: c) Calling a method on a null reference
Explanation:
A NullPointerException is thrown when attempting to dereference a null object.
Correct Answer: c) Throwable
Explanation:
Throwable is the superclass of all errors and exceptions in Java.
Correct Answer: c) Errors represent severe JVM problems, Exceptions can be handled
Explanation:
Errors like OutOfMemoryError are unrecoverable, while Exceptions are designed to be caught and handled.
Correct Answer: b) throw
Explanation:
The throw keyword is used to throw an exception explicitly from within a method.
Correct Answer: c) To declare exceptions a method might throw
Explanation:
The throws clause in a method signature indicates that the method may throw specific checked exceptions.
Correct Answer: c) To execute essential cleanup code regardless of exceptions
Explanation:
The finally block always executes, making it ideal for closing resources like file streams.
Correct Answer: b) Yes, if followed by a finally block
Explanation:
A try block must be paired with either a catch block or a finally block.
Correct Answer: c) IOException
Explanation:
IOException is checked by the compiler. The others are unchecked runtime exceptions.
Correct Answer: b) ArrayIndexOutOfBoundsException
Explanation:
ArrayIndexOutOfBoundsException is specifically thrown for illegal array access.
Correct Answer: b) NumberFormatException
Explanation:
NumberFormatException is thrown when a string does not contain a parsable integer.
Correct Answer: c) Iterable
Explanation:
Iterable is the root interface, which is extended by the Collection interface.
Correct Answer: b) No
Explanation:
Map operates on key-value pairs and has a separate hierarchy from Collection.
Correct Answer: b) List allows duplicates, Set does not
Explanation:
A List is an ordered collection that permits duplicate elements, while a Set does not.
Correct Answer: c) ArrayList uses a dynamic array, LinkedList uses a doubly linked list
Explanation:
ArrayList is backed by an array making random access fast, while LinkedList uses nodes making insertions faster.
Correct Answer: b) Vector
Explanation:
Vector is a legacy class and its methods are synchronized by default.
Correct Answer: c) TreeSet
Explanation:
TreeSet stores elements in their natural ordering or according to a provided Comparator.
Correct Answer: c) HashMap allows one null key, Hashtable allows none
Explanation:
Hashtable is synchronized and strictly prohibits null keys or values, while HashMap permits one null key and multiple null values.
Correct Answer: c) ConcurrentHashMap
Explanation:
ConcurrentHashMap uses lock striping, allowing concurrent reads and writes without locking the whole map.
Correct Answer: b) ListIterator traverses in both directions
Explanation:
ListIterator extends Iterator and provides bi-directional traversal for Lists.
Correct Answer: b) Throws ConcurrentModificationException on structural modification
Explanation:
Fail-fast iterators instantly throw an exception if the underlying collection is modified during iteration.
Correct Answer: c) Comparable
Explanation:
The Comparable interface provides the compareTo method to define the natural sorting behavior of objects.
Correct Answer: b) Comparator
Explanation:
The Comparator interface provides the compare method to implement custom, external sorting logic.
Correct Answer: c) run()
Explanation:
The run() method defines the entry point and execution logic for a thread.
Correct Answer: b) thread.start()
Explanation:
Calling start() instructs the JVM to allocate a new call stack and invoke the run() method asynchronously.
Correct Answer: b) Pauses execution for a specified time without releasing locks
Explanation:
sleep() pauses the current thread but retains any synchronized locks it holds.
Correct Answer: b) wait() releases the lock, sleep() does not
Explanation:
wait() belongs to the Object class and releases the monitor lock, whereas sleep() does not release locks.
Correct Answer: c) Causes current thread to wait until the joined thread completes
Explanation:
join() halts the current thread's execution until the thread on which join() was called has finished.
Correct Answer: c) A background thread that provides services to user threads
Explanation:
Daemon threads run in the background (like Garbage Collector) and do not prevent the JVM from exiting.
Correct Answer: b) 5
Explanation:
Thread priority ranges from 1 to 10. The default priority is 5 (NORM_PRIORITY).
Correct Answer: b) Two or more threads are blocked forever waiting on each other
Explanation:
Deadlock occurs when multiple threads wait indefinitely for locks held by one another.
Correct Answer: c) notify()
Explanation:
The notify() method wakes up a single thread waiting on the object's monitor.
Correct Answer: b) Automatic reclamation of memory by destroying unreferenced objects
Explanation:
Java automatically manages memory by reclaiming space from objects that are no longer reachable.
Correct Answer: a) System.gc()
Explanation:
System.gc() or Runtime.getRuntime().gc() suggests that the JVM perform garbage collection.
Correct Answer: c) finalize()
Explanation:
The finalize() method is invoked by the garbage collector before the object's memory is reclaimed.
Correct Answer: b) To convert primitive data types into objects
Explanation:
Wrapper classes encapsulate primitives so they can be used in collections that require objects.
Correct Answer: b) Automatic conversion of primitives to wrapper objects
Explanation:
Autoboxing is the compiler automatically converting a primitive type into its corresponding wrapper class.
Correct Answer: b) Converting wrapper object to primitive value
Explanation:
Unboxing is the reverse of autoboxing, converting a wrapper object back to a primitive type.
Correct Answer: a) Yes
Explanation:
Enums can implement interfaces, but they cannot extend classes because they implicitly extend java.lang.Enum.
Correct Answer: b) Metadata about a class, method, or field
Explanation:
Annotations provide metadata for the compiler or runtime environments, such as @Override.
Correct Answer: b) Compile-time type safety and eliminating casts
Explanation:
Generics provide strong type checking at compile time and eliminate the need for manual type casting.
Correct Answer: b) Replacing generic types with bounds or Object at compile time
Explanation:
Type erasure removes generic type parameters during compilation to maintain backward compatibility with older Java versions.
Correct Answer: a) Unknown type
Explanation:
The question mark (?) represents an unknown type parameter in generics.
Correct Answer: a) Converting object state to byte stream
Explanation:
Serialization converts an object into a byte stream for storage or transmission.
Correct Answer: a) java.io.Serializable
Explanation:
The Serializable interface acts as a marker to indicate that a class can be serialized.
Correct Answer: c) Verify sender and receiver class compatibility during deserialization
Explanation:
It ensures that the serialized object matches the loaded class structure during deserialization.
Correct Answer: d) Externalizable provides custom control over serialization
Explanation:
Externalizable requires implementing readExternal and writeExternal methods to manually control serialization.
Correct Answer: b) FileReader
Explanation:
FileReader reads streams of characters, whereas FileInputStream reads raw bytes.
Correct Answer: b) Buffers data for efficiency and provides readLine()
Explanation:
BufferedReader reads chunks into memory, speeding up reading and allowing line-by-line reads.
Correct Answer: c) java.io.File
Explanation:
The File class is an abstract representation of file and directory pathnames.
Correct Answer: c) Scanner
Explanation:
The Scanner class parses input into primitive types and strings using delimiters.
Correct Answer: c) array.length
Explanation:
For arrays, length is a final property, not a method, so no parentheses are used.
Correct Answer: d) All of the above
Explanation:
All listed syntaxes are syntactically valid for 2D arrays in Java.
Correct Answer: a) Creating an exact copy of an object
Explanation:
Cloning creates a new instance with the same state as the original object.
Correct Answer: a) CloneNotSupportedException
Explanation:
The Object clone() method throws this exception if the object's class does not implement the Cloneable interface.
Correct Answer: b) Copies primitives but object references point to the same memory
Explanation:
In a shallow copy, nested objects are not duplicated; their references are shared.
Correct Answer: b) Examine or modify runtime behavior of classes in JVM
Explanation:
Reflection allows dynamic inspection and manipulation of classes, methods, and fields at runtime.
Correct Answer: b) Dynamically loads a class at runtime
Explanation:
It locates, loads, and links a class dynamically during execution.
Correct Answer: a) Ensures a class has only one instance and a global point of access
Explanation:
Singleton is a creational pattern that limits object instantiation to a single object.
Correct Answer: b) Factory Pattern
Explanation:
The Factory Pattern abstracts the object creation process, classifying it as a creational pattern.
Correct Answer: a) Model View Controller
Explanation:
MVC separates application logic into Data (Model), UI (View), and Input logic (Controller).
Correct Answer: b) Load class files into the JVM at runtime
Explanation:
The ClassLoader is responsible for dynamically finding and loading Java class files into the JVM.
Correct Answer: a) Just In Time compiler, compiles bytecode to native code for performance
Explanation:
JIT improves performance by compiling bytecode into native machine code at runtime.
Correct Answer: b) Intermediate code generated by Java compiler for the JVM
Explanation:
Bytecode is a platform-independent instruction set executed by the Java Virtual Machine.
Correct Answer: a) Write Once, Run Anywhere
Explanation:
WORA emphasizes Java's cross-platform capabilities via bytecode.
Correct Answer: b) 2 bytes
Explanation:
Java uses 16-bit Unicode characters, so a char takes 2 bytes.
Correct Answer: b) double
Explanation:
Double is 64-bit and offers more precision than the 32-bit float.
Correct Answer: b) Narrowing casting
Explanation:
Narrowing requires an explicit cast and may result in loss of precision or data.
Correct Answer: b) No
Explanation:
Static nested classes do not have an implicit reference to an outer class instance.
Correct Answer: a) A non-static class defined within another class
Explanation:
Inner classes have access to all members of the outer class, including private ones.
Correct Answer: b) Nameless inner class instantiated once
Explanation:
It allows declaring and instantiating a class at the same time to make code more concise.
Correct Answer: c) Must be final or effectively final
Explanation:
Local variables must be final or effectively final to be used inside a local inner class.
Correct Answer: c) package
Explanation:
The package keyword organizes classes into namespaces, preventing naming conflicts.
Related Posts
No Image
Latest C++ Functions MCQs
1. What is the size of the int data type in Java? a) 2 bytes b) 4 bytes c) 8…
October 20, 2026By MCQs Generator

Important Java 8 Features MCQs
Released in March 2014, Java 8 represents one of the most significant upgrades in the history of the Java programming…
October 19, 2026By MCQs Generator

Java Multithreading & Concurrency MCQs
Java multithreading and concurrency are core pillars for building high-performance, responsive applications that execute multiple tasks simultaneously. Utilizing the java.util.concurrent…
October 19, 2026By MCQs Generator
Related Categories

AI & Data Science MCQ
5 topics
By MCQs Generator

Arts & Humanities MCQ
4 topics
By MCQs Generator

Civil Engineering MCQ
4 topics
By MCQs Generator

Commerce & Business MCQ
4 topics
By MCQs Generator

Competitive Exams MCQ
5 topics
By MCQs Generator

Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator

General Knowledge MCQ
2 topics
By MCQs Generator

General Science MCQ
4 topics
By MCQs Generator

Law & Judiciary MCQ
3 topics
By MCQs Generator

Mechanical Engineering MCQ
4 topics
By MCQs Generator

Medical & Health Sciences MCQ
4 topics
By MCQs Generator

Modern Tech Fields MCQ
3 topics
By MCQs Generator