Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q561: Which of the following statements about delete operator is correct?
  • A: It deallocates memory without calling the destructor.
  • B: It is used to deallocate memory for dynamic arrays without brackets.
  • C: It must be used with empty square brackets for dynamic arrays.
  • D: It calls the constructor before deallocating memory.
View Answer
C

Q562: What happens if you use delete instead of delete[] for an array of objects?
  • A: Only the first object in the array is deallocated.
  • B: All objects in the array are properly deallocated.
  • C: No memory is deallocated at all.
  • D: Only the destructor for the first object is called.
View Answer
A

Q563: How does overloading new operator affect memory allocation?
  • A: It changes the memory block initialization behavior.
  • B: It changes the memory block allocation strategy.
  • C: It affects only the destructor calls.
  • D: It prevents memory leaks by automatically managing memory.
View Answer
B

Q564: In a class with a custom new operator, what happens when a new object is created?
  • A: The constructor is called before memory allocation.
  • B: The memory is allocated before calling the constructor.
  • C: The object is created without initializing memory.
  • D: The destructor is called before memory allocation.
View Answer
B

Q565: What is the key reason for overloading new and delete operators in embedded systems?
  • A: To ensure consistent memory allocation and deallocation time.
  • B: To avoid using the default memory management provided by C++.
  • C: To prevent memory fragmentation in multi-threaded environments.
  • D: To simplify memory deallocation.
View Answer
A

Q566: What are the two types of streams in C++?
  • A: Input and Output Streams
  • B: File and Network Streams
  • C: Buffered and Unbuffered Streams
  • D: Character and Byte Streams
View Answer
A

Q567: Which of the following functions is used in C for formatted output?
  • A: printf
  • B: cout
  • C: cin
  • D: read
View Answer
A

Q568: What is the purpose of the cin stream in C++?
  • A: To display output on the screen
  • B: To perform mathematical operations
  • C: To take input from the keyboard
  • D: To read from a file
View Answer
C

Q569: How does the cin stream handle different data types?
  • A: It ignores data types and stores all as strings
  • B: It overloads operators to handle various types
  • C: It converts all data to binary representation
  • D: It processes input one character at a time
View Answer
B

Q570: What does the cout stream do?
  • A: It takes input from the user
  • B: It performs calculations
  • C: It displays output on the screen
  • D: It reads from a file
View Answer
C

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now