Multiple-Choice Questions (MCQ) on Basic Programming
Instructions: Choose the best answer for each question.
1. Which of the following is a high-level programming language?
a) Assembly
b) Machine Language
c) Python
d) Binary
Answer: c) Python
2. What does IDE stand for in programming?
a) Internal Development Environment
b) Integrated Development Environment
c) Internet Data Exchange
d) Interactive Debugging Engine
Answer: b) Integrated Development Environment
3. Which of the following is NOT a data type in Python?
a) Integer
b) String
c) Float
d) Character
Answer: d) Character
4. What symbol is used for a single-line comment in Python?
a) //
b) #
c) <!-- -->
d) /* */
Answer: b) #
5. Which of these loops is available in most programming languages?
a) if-else
b) switch-case
c) while
d) elif
Answer: c) while
6. What will be the output of print(3 * "Hello ") in Python?
a) Hello Hello Hello
b) HelloHelloHello
c) Error
d) None
Answer: a) Hello Hello Hello
7. Which function is used to take user input in Python?
a) scanf()
b) input()
c) get()
d) read()
Answer: b) input()
8. Which keyword is used to define a function in Python?
a) func
b) define
c) def
d) function
Answer: c) def
9. What is the correct way to declare a variable in Python?
a) var x = 5
b) int x = 5
c) x = 5
d) declare x = 5
Answer: c) x = 5
10.What does len("Python") return?
a) 5
b) 6
c) 7
d) Error
Answer: b) 6
11.What type of error occurs when a program is syntactically correct
but runs into an unexpected situation?
a) Syntax Error
b) Runtime Error
c) Logic Error
d) Compilation Error
Answer: b) Runtime Error
12.Which logical operator represents "AND" in Python?
a) &
b) &&
c) and
d) |
Answer: c) and
13.What will range(5) generate in Python?
a) 1, 2, 3, 4, 5
b) 0, 1, 2, 3, 4
c) 1, 2, 3, 4
d) Error
Answer: b) 0, 1, 2, 3, 4
14.Which of the following is used to terminate a loop in Python?
a) exit
b) break
c) continue
d) return
Answer: b) break
15.What will be the output of bool([]) in Python?
a) True
b) False
c) Error
d) None
Answer: b) False
Table of Specifications (TOS)
Number of
Topic Cognitive Level
Items
Remembering,
Programming Basics 5
Understanding
Data Types & Variables 3 Understanding, Applying
Control Structures (Loops,
4 Applying, Analyzing
Conditionals)
Functions & Input/Output 2 Applying
Debugging & Error Handling 1 Evaluating
Logical & Boolean Operators 2 Understanding, Applying
Total 15 Mixed Levels
Multiple-Choice Questions (MCQ) on Compiler and Interpreter
Instructions: Choose the best answer for each question.
1. Which of the following translates an entire program before
execution?
a) Interpreter
b) Compiler
c) Assembler
d) Debugger
Answer: b) Compiler
2. Which of these translates code line-by-line during execution?
a) Compiler
b) Assembler
c) Interpreter
d) Linker
Answer: c) Interpreter
3. Which of the following is an example of an interpreted language?
a) C
b) Java
c) Python
d) Assembly
Answer: c) Python
4. What is the main disadvantage of an interpreter compared to a
compiler?
a) It uses more memory
b) It is slower since it executes code line by line
c) It cannot detect syntax errors
d) It does not work on different operating systems
Answer: b) It is slower since it executes code line by line
5. Which of the following languages typically uses a compiler?
a) JavaScript
b) Python
c) C++
d) PHP
Answer: c) C++
6. Which of the following is NOT a phase of compilation?
a) Lexical Analysis
b) Syntax Analysis
c) Interpretation
d) Code Optimization
Answer: c) Interpretation
7. What is the purpose of a linker in compiled languages?
a) To execute the code line by line
b) To connect multiple object files into a single executable
c) To detect syntax errors
d) To analyze the logic of the code
Answer: b) To connect multiple object files into a single executable
8. Which programming language is both compiled and interpreted?
a) Java
b) C
c) Assembly
d) Swift
Answer: a) Java
9. Which of the following is an advantage of using a compiler?
a) It requires less memory to run
b) It executes programs faster than an interpreter
c) It allows immediate debugging while running the program
d) It does not require separate compilation
Answer: b) It executes programs faster than an interpreter
10.What does the lexical analyzer do in a compiler?
a) Converts source code into machine code
b) Breaks the code into tokens
c) Optimizes the program for better performance
d) Executes the program
Answer: b) Breaks the code into tokens
11.Which software component is responsible for checking the syntax of
a program?
a) Assembler
b) Parser
c) Linker
d) Debugger
Answer: b) Parser
12.Which of the following is NOT a function of an interpreter?
a) Translates high-level code to machine code
b) Executes the program step-by-step
c) Optimizes the entire code before execution
d) Allows immediate testing and debugging
Answer: c) Optimizes the entire code before execution
13.What is the primary purpose of Just-In-Time (JIT) compilation?
a) To execute programs in a single step
b) To convert bytecode into machine code at runtime
c) To analyze syntax errors before execution
d) To slow down the execution process
Answer: b) To convert bytecode into machine code at runtime
14.Which of the following is a major difference between a compiler and
an interpreter?
a) Compilers execute code line by line, while interpreters translate all at once
b) Interpreters execute code line by line, while compilers translate all at once
c) Both compilers and interpreters execute code the same way
d) Compilers do not check for errors, but interpreters do
Answer: b) Interpreters execute code line by line, while compilers translate all at
once
15.Which of the following is an example of a compiled programming
language?
a) JavaScript
b) Python
c) C
d) Ruby
Answer: c) C
Table of Specifications (TOS)
Number of
Topic Cognitive Level
Items
Remembering,
Basic Concepts of Compiler & Interpreter 4
Understanding
Understanding,
Differences Between Compiler & Interpreter 3
Applying
Phases of Compilation Process 3 Applying, Analyzing
Execution & Performance Differences 3 Analyzing, Evaluating
Real-World Examples of Compiled vs Understanding,
2
Interpreted Languages Applying
Total 15 Mixed Levels
Would you like any modifications or additional explanations? 😊