Programs MCQs with Answers

Programming Practice

Practice Programs MCQs with answers.

Distraction-free environment with keyboard shortcuts (1-4, Enter, Esc)

Programming / Programming

Programs MCQs

50 Questions

Practice Programs MCQs with answers.

0 / 201 answered0 correct0 incorrect

1What is the output of the following Python code snippet? print(bool(""), bool(" "), bool([]), bool([0]))

2What is the output of the following C code snippet? #include <stdio.h> int main() { int a = 5; int b = a > 2 ? 100 : 200; printf("%d", b); return 0; }

3What is the output of the following Python code snippet? d = {'a': 1, 'b': 2} print(list(d.keys()))

4What is the output of the following Python code snippet? x = {1, 2, 3} x.discard(4) print(len(x))

5What is the output of the following C++ code snippet? #include <iostream> using namespace std; int main() { int a = 10; int &ref = a; ref = 20; cout << a; return 0; }

6What is the output of the following Python code snippet? a = [1, 2] b = [3, 4] a.append(b) print(len(a))

7What is the output of the following Python code snippet? a = [1, 2] b = [3, 4] a.extend(b) print(len(a))

8What is the output of the following C code snippet? #include <stdio.h> int main() { int x = 1; printf("%d %d %d", x, ++x, x++); return 0; }

9What is the output of the following Python code snippet? x = [1, 2, 3] print(x.pop(1), x)

10What is the output of the following Java code snippet? public class Test { public static void main(String[] args) { try { int x = 5 / 0; } catch (Exception e) { System.out.print("Catch "); } finally { System.out.print("Finally"); } } }

11What is the output of the following C++ code snippet? #include <iostream> using namespace std; int main() { int a = 10, b = 20; swap(a, b); cout << a << " " << b; return 0; }

12What is the output of the following Python code snippet? s = "abracadabra" print(s.count('a'), s.count('ab'))

13What is the output of the following C code snippet? #include <stdio.h> int main() { int a = 0; for (int i = 0; i < 5; i++) { if (i == 2) continue; a += i; } printf("%d", a); return 0; }

14What is the output of the following Python code snippet? funcs = [lambda x, i=i: x + i for i in range(3)] res = [f(10) for f in funcs] print(res)

15What is the output of the following Python code snippet? funcs = [lambda x: x + i for i in range(3)] res = [f(10) for f in funcs] print(res)

16What is the output of the following C++ code snippet? #include <iostream> using namespace std; void fun(int x) { cout << "int "; } void fun(double x) { cout << "double "; } int main() { fun(5); fun(5.0); return 0; }

17What is the output of the following Java code snippet? public class Test { public static void main(String[] args) { int x = 5; System.out.println(x > 2 ? x < 4 ? 10 : 20 : 30); } }

18What is the output of the following Python code snippet? x = [[]] * 3 x[0].append('A') print(x)

19What is the output of the following Python code snippet? d = {1: 'a', True: 'b', 1.0: 'c'} print(len(d), d[1])

20What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Base { public: virtual void greet() { cout << "Hello "; } }; class Derived : public Base { public: void greet() override { cout << "Hi "; } }; int main() { Derived d; Base b = d; // Object slicing b.greet(); return 0; }

21What is the output of the following Python code snippet? x = (1, 2, 3) y = x y += (4, 5) print(x)

22What is the output of the following Python code snippet? x = [1, 2, 3] y = x y += [4, 5] print(x)

23What is the output of the following Python code snippet? a = (1) b = (1,) print(type(a).__name__, type(b).__name__)

24What is the output of the following Java code snippet? public class Test { public static void main(String[] args) { String s = "Java"; s.replace('a', 'o'); System.out.println(s); } }

25What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Counter { static int count; public: Counter() { count++; } static int getCount() { return count; } }; int Counter::count = 0; int main() { Counter c1, c2, c3; cout << Counter::getCount(); return 0; }

26What will happen when the following Python code snippet is executed? d = {'a': 1} print(d['b'])

27What will happen when the following Python code snippet is executed? a = [1, 2, 3] print(a[10])

28What is the output of the following Python code snippet? a = [1, 2, 3] print(a[10:])

29What is the output of the following C code snippet? #include <stdio.h> int main() { int a = 12; // 1100 in binary int res = a & (-a); printf("%d", res); return 0; }

30What is the output of the following Python code snippet? def func(): try: return 1 finally: print("Clean", end=" ") print(func())

31What is the output of the following C++ code snippet? #include <iostream> using namespace std; template <typename T> T myMax(T a, T b) { return (a > b) ? a : b; } int main() { cout << myMax(3, 7) << " " << myMax(5.5, 2.1); return 0; }

32What is the output of the following Java code snippet? public class Test { public static void main(String[] args) { Integer a = 100, b = 100; Integer c = 200, d = 200; System.out.println((a == b) + " " + (c == d)); } }

33What is the output of the following Python code snippet? gen = (x * 2 for x in range(3)) print(list(gen), list(gen))

34What is the output of the following Python code snippet? x = (i for i in range(3)) print(type(x).__name__)

35What is the output of the following C++ code snippet? #include <iostream> using namespace std; int main() { int x = 5; auto f = [&x]() { x += 10; return x; }; cout << f() << " " << x; return 0; }

36What is the output of the following C++ code snippet? #include <iostream> using namespace std; int main() { int x = 5; auto f = [x]() mutable { x += 10; return x; }; cout << f() << " " << x; return 0; }

37What is the output of the following Python code snippet? a = [1, 2, 3] b = ['a', 'b', 'c'] print(list(zip(a, b)))

38What is the output of the following Python code snippet? nums = [1, 2, 3, 4] print(any(x > 3 for x in nums), all(x > 0 for x in nums))

39What is the output of the following Python code snippet? try: a = 10 / 2 except ZeroDivisionError: print("Zero", end=" ") else: print("Else", end=" ") finally: print("Finally")

40What is the output of the following Python code snippet? try: a = 10 / 0 except ZeroDivisionError: print("Zero", end=" ") else: print("Else", end=" ") finally: print("Finally")

41What is the output of the following C code snippet? #include <stdio.h> int isPowerOfTwo(int n) { return (n > 0) && ((n & (n - 1)) == 0); } int main() { printf("%d %d", isPowerOfTwo(16), isPowerOfTwo(18)); return 0; }

42What is the output of the following Python code snippet? class Sample: x = 10 s1 = Sample() s2 = Sample() s1.x = 20 print(s1.x, s2.x, Sample.x)

43What is the output of the following Python code snippet? class A: count = 0 def __init__(self): A.count += 1 a1 = A() a2 = A() a3 = A() print(A.count)

44What is the output of the following Java code snippet? public class Test { static int test() { int x = 10; try { return x; } finally { x = 20; } } public static void main(String[] args) { System.out.println(test()); } }

45What is the output of the following Java code snippet? public class Test { static int test() { try { return 10; } finally { return 20; } } public static void main(String[] args) { System.out.println(test()); } }

46What is the output of the following Java code snippet? class Parent { public static void print() { System.out.print("Parent "); } } class Child extends Parent { public static void print() { System.out.print("Child "); } } public class Main { public static void main(String[] args) { Parent p = new Child(); p.print(); } }

47What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Base { public: virtual void show() { cout << "Base "; } }; class Derived : public Base { public: void show() override { cout << "Derived "; } }; int main() { Base *ptr = new Derived(); ptr->show(); return 0; }

48What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Base { public: void show() { cout << "Base "; } }; class Derived : public Base { public: void show() { cout << "Derived "; } }; int main() { Base *ptr = new Derived(); ptr->show(); return 0; }

49What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Base { public: ~Base() { cout << "~B "; } }; class Derived : public Base { public: ~Derived() { cout << "~D "; } }; int main() { Derived obj; return 0; }

50What is the output of the following C++ code snippet? #include <iostream> using namespace std; class Base { public: Base() { cout << "B "; } }; class Derived : public Base { public: Derived() { cout << "D "; } }; int main() { Derived obj; return 0; }

Previous TopicTopic 1 of 49 · More questions availableNext Topic

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.

Targeted Exam Preparation

MCQs for Competitive Exams

Prepare with exam-specific question banks tailored to syllabi, previous years' question papers, and negative-marking criteria.

Teaching Exam

BPSC TRE 2.0 Computer Science

Practice BPSC TRE 2.0 Class 11-12 Computer Science previous-year questions with solutions.

Teaching Exam

BPSC TRE 3.0 Computer Science

Practice BPSC TRE 3.0 Class 11-12 Computer Science previous-year questions with solutions.

Teaching Exam

BPSC TRE 4.0 Computer Science

Practice BPSC TRE 4.0 Class 11-12 Computer Science previous-year questions with solutions.

Teaching Eligibility Test

Bihar STET Paper II Computer Science

Practice Bihar STET Paper II Class 11-12 Computer Science questions with solutions.

National Exam

GATE Computer Science (CSE)

High-yield engineering questions covering Algorithms, Theory of Computation, Compiler Design, Computer Organization, and Operating Systems.

Assistant Professor & JRF

UGC NET Computer Science

Comprehensive question sets aligned with NTA UGC NET Paper II syllabus, featuring theoretical foundations, discrete math, and systems.

Government Recruitment

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.