Basics of Introduction to Programming Languages MCQs

By: Prof. Dr. Fazal Rehman | Last updated: September 28, 2024

What is a programming language? A) A set of instructions for a computer to perform tasks B) A type of hardware C) A database management system D) A computer virus Answer: A Which of the following is a high-level programming language? A) Assembly B) C C) Machine Code D) Binary Answer: B What is the main purpose of a compiler? A) To run code B) To translate high-level code into machine code C) To debug programs D) To create user interfaces Answer: B Which of the following is NOT a programming paradigm? A) Object-Oriented Programming B) Functional Programming C) Structured Programming D) Hardware Programming Answer: D What is an algorithm? A) A programming language B) A step-by-step procedure for solving a problem C) A type of software D) A compiler Answer: B Which of the following is an example of a procedural programming language? A) Java B) Python C) C D) HTML Answer: C What does the term ‘syntax’ refer to in programming? A) The meaning of a statement B) The structure and rules governing the composition of statements C) The speed of execution D) The storage method of data Answer: B Which of the following is used for defining a variable in Python? A) var B) let C) def D) = Answer: D What does ‘debugging’ mean in programming? A) Running the program B) Removing errors from code C) Compiling code D) Designing algorithms Answer: B What is the output of the following Python code: print(2 + 3 * 5)? A) 25 B) 17 C) 15 D) 20 Answer: B Which data structure uses LIFO (Last In, First Out)? A) Queue B) Stack C) Array D) List Answer: B What is the purpose of comments in programming? A) To execute code B) To store data C) To explain code and make it more readable D) To increase execution speed Answer: C Which of the following is a characteristic of an object-oriented programming language? A) It uses functions only B) It allows for the creation of classes and objects C) It is only suitable for web development D) It does not support encapsulation Answer: B What does ‘encapsulation’ mean in programming? A) Hiding data and providing access through methods B) Grouping functions together C) Storing data in an array D) Sharing data between programs Answer: A Which of the following languages is primarily used for web development? A) Python B) Java C) HTML D) C++ Answer: C What is a function in programming? A) A variable that stores data B) A block of code designed to perform a specific task C) A type of loop D) A conditional statement Answer: B What is the purpose of an integrated development environment (IDE)? A) To run programs B) To compile code only C) To provide tools for coding, testing, and debugging D) To store databases Answer: C What is the main advantage of using libraries in programming? A) They slow down execution B) They provide pre-written code for common tasks C) They require more memory D) They limit functionality Answer: B Which of the following is a feature of functional programming? A) State management B) Immutability C) Object creation D) Side effects Answer: B What is a variable? A) A constant value B) A named storage location in memory C) A type of loop D) A programming language Answer: B Which of the following is NOT a primitive data type? A) Integer B) String C) Float D) Array Answer: D What does the term ‘iteration’ refer to in programming? A) The process of executing code once B) The process of executing a block of code repeatedly C) The creation of a function D) The declaration of a variable Answer: B Which of the following is an example of a conditional statement? A) for loop B) if-else statement C) function definition D) variable declaration Answer: B What is the purpose of a return statement in a function? A) To end the program B) To call another function C) To output a value from the function D) To create a loop Answer: C Which operator is used for concatenation in Python? A) + B) & C) . D) * Answer: A Which of the following is NOT a valid variable name in Python? A) myVariable B) 1stVariable C) my_variable D) variable1 Answer: B What does API stand for in programming? A) Application Programming Interface B) Advanced Programming Interface C) Application Protocol Interface D) Automated Programming Interface Answer: A Which of the following is a common use of arrays in programming? A) To store multiple values in a single variable B) To increase execution time C) To create functions D) To define variables Answer: A What is an infinite loop? A) A loop that executes only once B) A loop that executes a fixed number of times C) A loop that never terminates D) A loop that runs in the background Answer: C Which of the following keywords is used to define a class in Python? A) define B) class C) function D) object Answer: B What is recursion in programming? A) A method that calls itself B) A type of loop C) A data structure D) A conditional statement Answer: A Which of the following best describes a syntax error? A) An error in the logic of the program B) A mistake in the spelling or grammar of the code C) An error that occurs during runtime D) A missing variable Answer: B What is the purpose of a constructor in a class? A) To execute code at the end of a program B) To initialize objects of the class C) To create variables D) To define functions Answer: B Which of the following is a widely used programming language for data science? A) Ruby B) Java C) R D) Pascal Answer: C What does the ‘this’ keyword refer to in object-oriented programming? A) The previous object B) The current object C) A global variable D) A function Answer: B Which type of error occurs when the program runs but produces incorrect results? A) Syntax error B) Logical error C) Runtime error D) Compilation error Answer: B What is a library in programming? A) A collection of pre-written code B) A database C) A type of software D) A programming language Answer: A Which of the following statements is used to include a library in a C++ program? A) include <library> B) import library C) #include <library> D) load library Answer: C Which of the following is an example of a database management language? A) SQL B) C++ C) JavaScript D) HTML Answer: A What does the term ‘scope’ refer to in programming? A) The distance between two variables B) The context in which a variable is defined and accessible C) The speed of execution D) The size of a program Answer: B Which of the following is a common use of loops in programming? A) To create functions B) To repeat a block of code multiple times C) To define variables D) To store data Answer: B What is the purpose of the ‘break’ statement in a loop? A) To skip the current iteration B) To end the loop prematurely C) To start a new loop D) To continue to the next iteration Answer: B Which of the following data types is used to store true/false values? A) Integer B) Float C) Boolean D) String Answer: C What is the output of the following code: print(“Hello”[1])? A) H B) e C) l D) o Answer: B Which keyword is used to handle exceptions in Python? A) catch B) handle C) try D) except Answer: C What does the term ‘inheritance’ mean in object-oriented programming? A) Creating a new class from an existing class B) The process of hiding data C) Overriding functions D) Creating a loop Answer: A Which of the following is a characteristic of interpreted languages? A) They are compiled before execution B) They are executed line by line C) They are faster than compiled languages D) They require additional software to run Answer: B What is the function of a return type in a function definition? A) It specifies the data type of the returned value B) It is optional and can be omitted C) It defines the name of the function D) It determines the execution speed Answer: A Which of the following best describes a data structure? A) A way to store and organize data B) A type of variable C) A programming language D) A function Answer: A  
All Copyrights Reserved 2025 Reserved by T4Tutorials