Java MCQs with Answers
Programming PracticePractice curated Java MCQs with instant answers, scoring, and detailed technical explanations.
Programming / Java
Java Comprehensive Practice MCQs
50 QuestionsPractice curated Java MCQs with instant answers, scoring, and detailed technical explanations.
2What does the JVM command-line option '-Xms' and '-Xmx' configure?
3What is the output of the following Java program? System.out.println(Boolean.TYPE == boolean.class);
4What is the purpose of 'StandardCopyOption.REPLACE_EXISTING' in Files.copy() or Files.move()?
5What method in java.lang.Class is used to create a new instance of a class reflectively without using deprecated newInstance()?
6What is the purpose of the 'java.lang.instrument.Instrumentation' API in Java?
7What does 'Path.normalize()' do in java.nio.file?
8What does 'Path.relativize(Path other)' do?
9What does 'Path.resolve(Path other)' in java.nio.file do?
10What is the purpose of 'java.nio.file.WatchService' in NIO.2?
11What is the output of the following Java code? File file = new File("nonexistent.txt"); System.out.println(file.exists());
12Which of the following types CANNOT be used as an element (attribute) return type in an annotation declaration?
13What meta-annotation introduced in Java 8 allows applying the same annotation type multiple times to the same declaration?
14What does the '@Inherited' meta-annotation do in Java?
15Which meta-annotation specifies the kinds of program elements (e.g. TYPE, METHOD, FIELD) to which an annotation can be applied?
16Which RetentionPolicy must be specified on a custom annotation to make it readable at runtime using reflection (e.g. method.getAnnotation(...))?
17What is the default RetentionPolicy for a custom annotation if no '@Retention' meta-annotation is specified?
18How does the Java 9+ Module System restrict 'setAccessible(true)' across module boundaries?
19What does calling 'field.setAccessible(true)' do in Java Reflection?
20What is the difference between 'Class.getMethods()' and 'Class.getDeclaredMethods()' in Java Reflection?
21What does the method 'Class.forName(String className)' do?
22How do you obtain the Class object representing class 'String' in Java?
23What is a 'direct buffer' (e.g. ByteBuffer.allocateDirect(int capacity)) in Java NIO?
24What is the purpose of the 'clear()' method on a java.nio.Buffer?
25What is the purpose of the 'flip()' method on a java.nio.Buffer (like ByteBuffer)?
26What does 'Files.walk(Path start)' in NIO.2 do?
27Why should 'Files.lines(Path path)' be used inside a try-with-resources statement?
28What does 'Files.lines(Path path)' return in Java 8+?
29How can you write a String directly to a file in a single statement in Java 11+?
30How can you read an entire file into a String in a single line of code in Java 11+?
31What is the effect of marking a field with the 'transient' keyword during serialization?
32What happens during deserialization if the serialVersionUID of the stream does NOT match the serialVersionUID of the local class?
33What is the role of the 'serialVersionUID' field in a class implementing java.io.Serializable?
34Which class should be used to wrap a FileReader for efficient line-by-line reading of a text file?
35What is the difference between Byte Streams and Character Streams in java.io?
36What exception is thrown by the JVM when the heap runs out of memory and the GC cannot reclaim sufficient space?
37What is a common cause of a memory leak in Java despite automatic garbage collection?
38What does calling 'System.gc()' or 'Runtime.getRuntime().gc()' do in Java?
39What is the purpose of java.lang.ref.PhantomReference in Java?
40What is the difference between a Strong Reference, a SoftReference, and a WeakReference in Java?
41What is the 'Epsilon' Garbage Collector introduced in Java 11 (-XX:+UseEpsilonGC)?
42What low-level technique enables ZGC to perform concurrent object relocation and compaction without stopping application threads?
43What is the primary design goal of the Z Garbage Collector (ZGC) introduced as a production feature in Java 15?
44How does the G1 (Garbage-First) collector partition the Java heap differently from legacy collectors?
45What is the default Garbage Collector in standard HotSpot 64-bit server JVMs starting in Java 9?
46What is a 'Stop-The-World' (STW) pause during Garbage Collection?
47What triggers the promotion of an object from the Survivor space to the Old (Tenured) Generation?
48What is a 'Minor GC' in Java?
49What are the components of the Young Generation in the HotSpot JVM heap?
50What is the 'Weak Generational Hypothesis' upon which modern JVM Garbage Collectors are designed?
Comprehensive Question Hub
Subject-Wise MCQ Practice
Select any core Computer Science or programming subject below to access dedicated practice questions, answers, and topic-wise modules.
Practice Computer Science MCQs27 Core Subjects
Fundamental CS engineering subjects covering systems, theory, and data architecture.
Programming Language MCQs9 Languages
Practice coding output questions, language syntax, OOP paradigms, and standard libraries.
MCQs for Competitive Exams
Prepare with exam-specific question banks tailored to syllabi, previous years' question papers, and negative-marking criteria.
BPSC TRE 2.0 Computer Science
Practice BPSC TRE 2.0 Class 11-12 Computer Science previous-year questions with solutions.
BPSC TRE 3.0 Computer Science
Practice BPSC TRE 3.0 Class 11-12 Computer Science previous-year questions with solutions.
BPSC TRE 4.0 Computer Science
Practice BPSC TRE 4.0 Class 11-12 Computer Science previous-year questions with solutions.
Bihar STET Paper II Computer Science
Practice Bihar STET Paper II Class 11-12 Computer Science questions with solutions.
GATE Computer Science (CSE)
High-yield engineering questions covering Algorithms, Theory of Computation, Compiler Design, Computer Organization, and Operating Systems.
UGC NET Computer Science
Comprehensive question sets aligned with NTA UGC NET Paper II syllabus, featuring theoretical foundations, discrete math, and systems.
SSC & State Technical Exams
Foundational and practical MCQs for technical assistants, programmers, and informatics officers in central and state departments.
Why Practice MCQs on CodeZov?
A modern, high-yield practice platform designed to build speed, accuracy, and deep conceptual clarity.
Instant Answers & In-Depth Explanations
Receive immediate validation with step-by-step technical explanations and code breakdown so you learn from mistakes on the spot.
Full-Screen Distraction-Free Exam Mode
Simulate authentic exam environments with dedicated Full-Screen mode, keyboard shortcuts (1-4, A-D, Enter), and a live question matrix.
Topic-Wise & Subject-Wise Syllabus
Explore modular practice sets across Data Structures, Algorithms, DBMS, Operating Systems, Computer Networks, and modern programming languages.
Previous Year Questions (PYQs)
Solve authentic previous year questions adapted from BPSC TRE Computer Science, GATE CSE, and UGC NET question papers.
Ready to Deepen Your Conceptual Knowledge?
MCQ practice is most effective when paired with structured conceptual tutorials, career roadmaps, and full-length timed mock tests. Check out CodeZov's free resources to boost your preparation.
Core Syllabus Coverage
- Programming (C, C++, Java, Python, SQL)
- Data Structures & Algorithms
- Database Management Systems (DBMS)
- Operating Systems & Architecture
- Computer Networks & Cybersecurity
Frequently Asked Questions
Answers to common questions about practicing Computer Science MCQs on CodeZov.
What are MCQs?
Multiple-Choice Questions (MCQs) are objective assessment questions where learners select the correct option from multiple choices. In Computer Science, MCQs evaluate theoretical understanding, code snippet outputs, algorithm time complexities, and system architecture fundamentals.
Can I practice Computer Science MCQs online?
Yes, CodeZov offers 100% free online Computer Science MCQ practice with instant scoring, step-by-step explanations, code execution analysis, and Hindi translations without requiring mandatory registration or fees.
Are MCQs available topic-wise?
Yes, all questions on CodeZov are systematically organized by subject (such as DBMS, Operating Systems, Data Structures) and further categorized into specific topics (such as Trees, Normalization, CPU Scheduling, and TCP/IP) for focused preparation.
Do MCQs include answers and explanations?
Every MCQ on CodeZov features verified correct answers alongside in-depth conceptual explanations. Many questions also include bilingual Hindi explanations and line-by-line code breakdowns to ensure complete conceptual clarity.
Which subjects are available for MCQ practice?
CodeZov provides MCQs across over 40 technical subjects including C Programming, C++, Java, Python, Data Structures, Algorithms, DBMS, Operating Systems, Computer Networks, Theory of Computation, Compiler Design, Digital Logic Design, and Software Engineering.
Can I use MCQs to prepare for competitive exams?
Yes, our question bank is specifically curated for competitive examinations including BPSC TRE Computer Science (Class 11-12), GATE CSE, NTA UGC NET / JRF, ISRO, NIELIT, Kendriya Vidyalaya (KVS/NVS) PGT Computer Science, and university semester exams.