Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Multiple Choice Questions
Q701: What does the operator + (double d) function do?
- A: Adds a matrix to a matrix
- B: Adds a scalar to each element in the matrix
- C: Subtracts a scalar from the matrix
- D: Multiplies matrix with a scalar
View Answer
B
Q702: How does the input(istream &is) function interact with the user?
- A: It prompts the user for input
- B: It reads from a file
- C: It outputs to the console
- D: It writes to a file
View Answer
A
Q703: What is the default constructor of the Matrix class?
- A: Initializes rows to zero
- B: Initializes columns to zero
- C: Initializes both rows and columns to zero
- D: Does nothing
View Answer
C
Q704: What does the assignment operator function return in the Matrix class?
- A: A pointer to a matrix
- B: A reference to a matrix
- C: A copy of the matrix
- D: A constant value
View Answer
B
Q705: Why is the assignment operator function marked as const?
- A: To allow modifications
- B: To prevent assignment to the returned reference
- C: To increase efficiency
- D: To simplify the code
View Answer
B
Q706: What is the purpose of checking if( &m != this) in the assignment operator?
- A: To prevent memory leaks
- B: To check if matrices are equal
- C: To prevent self-assignment
- D: To optimize memory usage
View Answer
C
Q707: What happens if the number of rows and columns in the matrices are not the same in the assignment operator?
- A: Nothing happens
- B: The matrix on the left is resized
- C: An error is thrown
- D: The program crashes
View Answer
B
Q708: In the addition operator, what is returned after adding two matrices?
- A: A reference to the new matrix
- B: A new matrix
- C: The sum of elements
- D: A pointer to the new matrix
View Answer
B
Q709: What is the primary difference between a + d and d + a in the context of matrix operations?
- A: No difference
- B: They produce different results
- C: Only a + d is valid
- D: Only d + a is valid
View Answer
B
Q710: What does the multiplication operator function check before multiplying two matrices?
- A: If matrices have the same size
- B: If matrices are conformable for multiplication
- C: If the matrices are identical
- D: If the result will be a square matrix
View Answer
B