Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q621: How do you obtain the address of a variable in C++?
  • A: Using *
  • B: Using &
  • C: Using ->
  • D: Using .
View Answer
B

Q622: Which operator is used for dynamic memory allocation in C++?
  • A: malloc
  • B: calloc
  • C: new
  • D: alloc
View Answer
C

Q623: What is the role of the delete operator in C++?
  • A: To allocate memory
  • B: To deallocate memory
  • C: To create a new pointer
  • D: To initialize memory
View Answer
B

Q624: How is a reference different from a pointer?
  • A: A reference can point to nothing
  • B: A reference must always point to something
  • C: A reference is a type of pointer
  • D: A reference is a special pointer
View Answer
B

Q625: What does call by value mean in function arguments?
  • A: Passing the address of the variable
  • B: Passing the variable itself
  • C: Passing a copy of the variable
  • D: Passing a reference to the variable
View Answer
C

Q626: When is a copy constructor used?
  • A: When copying a reference
  • B: When copying a pointer
  • C: When creating a copy of an object
  • D: When deleting an object
View Answer
C

Q627: What happens if you assign one object to another without an overloaded assignment operator?
  • A: The new object is completely independent
  • B: The two objects point to the same memory
  • C: The original object is deleted
  • D: The memory is automatically freed
View Answer
B

Q628: What does new int [10] do in C++?
  • A: Allocates memory for 10 integers
  • B: Allocates memory for 10 characters
  • C: Deallocates memory for 10 integers
  • D: Deallocates memory for 10 characters
View Answer
A

Q629: How should you handle memory deallocation for arrays allocated with new?
  • A: delete p
  • B: delete [] p
  • C: free(p)
  • D: delete(p)
View Answer
B

Q630: When is the destructor of a contained object called in relation to the containing object?
  • A: Before the containing object
  • B: After the containing object
  • C: Simultaneously with the containing object
  • D: Independently of the containing object
View Answer
B

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now