We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10
Programming Concepts MCQs
1. What is the purpose of a variable in programming?
A) To store and manipulate data. (Correct Answer) B) To perform mathematical operations. C) To create loops. D) To define functions. 2. Which of the following is a valid identifier in most programming languages? A) 123variable B) _myVariable (Correct Answer) C) break D) 2ndVariable 3. What is the result of the expression 5 + 3 * 2 in most programming languages? A) 16 B) 11 (Correct Answer) C) 26 D) 13 4. In object-oriented programming, what is encapsulation? A) Breaking a program into smaller parts. B) Combining data and methods that operate on the data into a single unit. (Correct Answer) C) Writing code without comments. D) Using inheritance to create new classes. 5. What does the term "DRY" stand for in programming? A) Don't Run Yet. B) Do Run Yesterday. C) Don't Repeat Yourself. (Correct Answer) D) Do Run Yearly. 6. Which of the following is a primitive data type? A) List B) Float (Correct Answer) C) Class D) Array 7. What is the purpose of the "if" statement in programming? A) To declare variables. B) To create loops. C) To perform conditional execution. (Correct Answer) D) To define functions. 8. What is the purpose of the "break" statement in a loop? A) To exit the program. B) To skip the next iteration of the loop. C) To exit the loop. (Correct Answer) D) To resume the loop from the beginning. 9. In programming, what is the role of a function? A) To store data. B) To perform a specific task or calculation. (Correct Answer) C) To create loops. D) To define variables. 10. What is the primary purpose of comments in code? A) To confuse other programmers. B) To slow down the execution of the program. C) To provide explanations and documentation. (Correct Answer) D) To hide code from the compiler. 11. Which of the following is an example of a loop in programming? A) if (condition) { /* code */ } B) while (condition) { /* code */ } (Correct Answer) C) function myFunction() { /* code */ } D) float myVariable = 5.0; 12. What is the purpose of the "return" statement in a function? A) To terminate the program. B) To skip the next iteration of the loop. C) To exit the function and return a value. (Correct Answer) D) To declare a variable. 13. In programming, what does the term "scope" refer to? A) The physical size of the code file. B) The color scheme used in the code editor. C) The region of code where a variable is accessible. (Correct Answer) D) The process of commenting out code. 14. What is the purpose of the modulo operator (%) in programming? A) To perform addition. B) To find the square root. C) To get the remainder of a division. (Correct Answer) D) To concatenate strings. 15. Which of the following is an example of a syntax error in programming? A) var x = 10; B) if (condition) { /* code */ } C) print("Hello, World!"); D) for i in range(5): (Correct Answer) 16. What does the term "bug" refer to in programming? A) A feature in the code. B) A typo in the comments. C) An error or defect in the code. (Correct Answer) D) A part of the code intentionally left incomplete. 17. Which data structure follows the First In, First Out (FIFO) principle? A) Stack B) Queue (Correct Answer) C) Linked List D) Tree 18. What is the role of the "else" statement in programming? A) To create loops. B) To define functions. C) To specify an alternative block of code to execute if the "if" condition is false. (Correct Answer) D) To declare variables. 19. In programming, what does the term "iteration" mean? A) The process of defining variables. B) The process of commenting out code. C) The repetition of a block of code. (Correct Answer) D) The creation of objects. 20. What is the purpose of the "continue" statement in a loop? A) To exit the loop. B) To skip the next iteration of the loop. C) To continue to the next iteration of the loop. (Correct Answer) D) To restart the loop. 21. Which of the following is an example of a logical operator in programming? A) + B) / C) && (Correct Answer) D) ; 22. What is the role of the "try...catch" block in programming? A) To declare variables. B) To create loops. C) To handle exceptions and errors. (Correct Answer) D) To define functions. 23. What is the purpose of the "switch" statement in programming? A) To create loops. B) To perform conditional execution based on multiple cases. (Correct Answer) C) To declare variables. D) To define functions. 24. In programming, what does the term "compiler" do? A) Executes the program. B) Translates the code into machine language. (Correct Answer) C) Provides an environment for code execution. D) Handles exceptions and errors. 25. What is the primary role of the "new" keyword in object-oriented programming? A) To create a new program file. B) To allocate memory for a new object. (Correct Answer) C) To perform mathematical operations. D) To declare a new variable. 26. Which of the following is an example of an arithmetic operator in programming? A) = B) += C) * (Correct Answer) D) == 27. What does the term "polymorphism" mean in object-oriented programming? A) Having multiple functions with the same name in a program. B) The ability of a class to inherit properties from multiple classes. C) The ability of objects to take on different forms or types. (Correct Answer) D) The process of converting code into machine language. 28. What is the purpose of the "super" keyword in object-oriented programming? A) To create a superclass. B) To invoke the superclass's method. (Correct Answer) C) To declare variables. D) To perform mathematical operations. 29. In programming, what is the purpose of the "break" statement in a switch-case block? A) To exit the program. B) To exit the switch-case block. (Correct Answer) C) To skip the next case. D) To restart the switch-case block. 30. What does the term "bitwise AND" mean in programming? A) Combining two numbers using addition. B) Performing a logical AND operation on each pair of corresponding bits. (Correct Answer) C) Breaking down a number into its binary representation. D) Combining two strings. 31. What is the role of the "this" keyword in object-oriented programming? A) To declare variables. B) To reference the current instance of a class. (Correct Answer) C) To create loops. D) To exit a function. 32. Which of the following is an example of a relational operator in programming? A) && B) == C) > (Correct Answer) D) ; 33. What is the purpose of the "final" keyword in Java programming? A) To indicate the end of a program. B) To make a variable constant. (Correct Answer) C) To create loops. D) To declare a final class. 34. In object-oriented programming, what is an "interface"? A) A graphical user interface. B) A way to create loops. C) A contract specifying a set of methods that a class must implement. (Correct Answer) D) A type of loop. 35. What is the purpose of the "static" keyword in programming? A) To create a static class. B) To indicate a variable that can be changed. C) To define a method or variable that belongs to the class rather than an instance. (Correct Answer) D) To create loops. 36. What does the term "runtime" refer to in programming? A) The time it takes to write code. B) The time it takes to compile code. C) The time when a program is executed. (Correct Answer) D) The time it takes to design algorithms. 37. Which of the following is an example of a unary operator in programming? A) + B) / C) ! (Correct Answer) D) ; 38. What is the role of the "public" keyword in Java programming? A) To create a public variable. B) To indicate a method that can be accessed from outside the class. (Correct Answer) C) To create loops. D) To declare a public class. 39. In programming, what does the term "inheritance" mean in the context of classes? A) The ability of a class to take on multiple forms. B) The process of creating a new class. C) The process of acquiring the properties and behaviors of an existing class. (Correct Answer) D) The process of defining variables. 40. What is the purpose of the "volatile" keyword in programming? A) To create a volatile variable. B) To indicate a variable that can be changed. C) To specify that a variable may be changed by multiple threads simultaneously. (Correct Answer) D) To create loops. 41. Which of the following is an example of a conditional (ternary) operator in programming? A) && B) == C) ? : (Correct Answer) D) ; 42. What is the purpose of the "const" keyword in programming? A) To create a constant variable. (Correct Answer) B) To create a constructor. C) To indicate the end of a program. D) To create loops. 43. In object-oriented programming, what is a "constructor"? A) A method that creates objects. B) A type of loop. C) A special method that is called when an object is created. (Correct Answer) D) A way to declare variables. 44. What does the term "garbage collection" refer to in programming? A) Throwing away unused code. B) Automatically reclaiming memory occupied by objects no longer in use. (Correct Answer) C) Collecting data for analysis. D) Deleting comments from code. 45. What is the purpose of the "abstract" keyword in Java programming? A) To create an abstract class. B) To indicate that a method has no implementation in the current class. (Correct Answer) C) To create loops. D) To declare an abstract variable. 46. Which of the following is an example of an assignment operator in programming? A) + B) / C) = (Correct Answer) D) == 47. What is the role of the "protected" keyword in programming? A) To create a protected variable. B) To indicate a variable that can only be accessed within its own class. C) To indicate that a method or variable can only be accessed within its own package or by subclasses. (Correct Answer) D) To create loops. 48. What is the purpose of the "NaN" value in programming? A) To represent a negative number. B) To indicate an error or undefined value in floating-point arithmetic. (Correct Answer) C) To create loops. D) To represent infinity. 49. Which of the following is an example of a bitwise OR operator in programming? A) && B) || C) | (Correct Answer) D) ; 50.What is the purpose of the "volatile" keyword in C programming? A) To declare a variable as constant. B) To indicate that a variable's value may change at any time outside the program's control. (Correct Answer) C) To specify that a function cannot modify the variable. D) To allocate memory for a variable dynamically