Computer Knowledge
Programming Fundamentals
2,381 Questions
Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.
Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references
Programming Fundamentals Questions
What is the most common type of buffer overflow vulnerability?
-
Stack overflow
-
Heap overflow
-
Format string overflow
-
Integer overflow
A
Correct answer
Explanation
Stack overflow occurs when a program writes data beyond the end of a stack buffer, overwriting other data on the stack.
Which of the following is not a common type of error?
-
Syntax errors
-
Runtime errors
-
Logical errors
-
User errors
C
Correct answer
Explanation
Logical errors are not a type of error in a computer program. They are errors in the logic of the program, which can cause the program to produce incorrect results.
Which of the following is not a common error-handling technique?
-
Try-catch blocks
-
Throw statements
-
Assert statements
-
Ignore errors
D
Correct answer
Explanation
Ignoring errors is not a common error-handling technique. It is generally considered to be bad practice, as it can lead to unexpected results.
Which of the following is not a common type of user error?
-
Mistyping
-
Misunderstanding the instructions
-
Entering invalid data
-
All of the above
D
Correct answer
Explanation
Mistyping, misunderstanding the instructions, and entering invalid data are all common types of user errors.
What is the best way to handle errors that occur in a process?
-
Use a try-catch block
-
Use a throw statement
-
Use an assert statement
-
All of the above
A
Correct answer
Explanation
The best way to handle errors that occur in a process is to use a try-catch block.
Which of the following is a common type of error in quantum programs?
-
Syntax errors
-
Logical errors
-
Runtime errors
-
All of the above
D
Correct answer
Explanation
Common types of errors in quantum programs include syntax errors, logical errors, and runtime errors.
What is the primary data structure used in NumPy for representing matrices?
-
ndarray
-
list
-
tuple
-
dictionary
A
Correct answer
Explanation
NumPy's ndarray (n-dimensional array) is the primary data structure for representing matrices and tensors, enabling efficient linear algebra operations.
What is the primary data structure used in Eigen for representing matrices?
-
MatrixXd
-
VectorXd
-
ArrayXd
-
TensorXd
A
Correct answer
Explanation
In Eigen, MatrixXd is the primary data structure for representing dense matrices, providing efficient access and manipulation of matrix elements.
What is the primary data structure used in Julia's LinearAlgebra package for representing matrices?
-
Matrix
-
Vector
-
Array
-
DataFrame
A
Correct answer
Explanation
In Julia's LinearAlgebra package, the Matrix data structure is used to represent matrices, offering efficient operations and manipulation.
What is the primary data structure used in MATLAB for representing matrices?
-
matrix
-
array
-
vector
-
table
A
Correct answer
Explanation
In MATLAB, the matrix data structure is used to represent matrices, enabling efficient operations and manipulation of matrix elements.
What is the primary data structure used in R's Matrix package for representing matrices?
-
matrix
-
array
-
vector
-
data.frame
A
Correct answer
Explanation
In R's Matrix package, the matrix data structure is used to represent matrices, offering efficient operations and manipulation of matrix elements.
-
A Type II error is rejecting the null hypothesis when it is false.
-
A Type II error is accepting the null hypothesis when it is true.
-
A Type II error is making a false positive decision.
-
A Type II error is making a false negative decision.
Correct answer
Explanation
A Type II error is accepting the null hypothesis when it is false, also known as a false negative decision.
What is the purpose of a loop in programming?
-
To execute a block of code repeatedly
-
To store data in memory
-
To compare values and make decisions
-
To input and output data
A
Correct answer
Explanation
A loop in programming allows a block of code to be executed repeatedly until a certain condition is met.
What is the purpose of a variable in programming?
-
To store data temporarily
-
To perform calculations
-
To control the flow of a program
-
To input and output data
A
Correct answer
Explanation
A variable in programming is used to store data temporarily, allowing it to be accessed and modified throughout the program.
What is the process of identifying and fixing errors in a program called?
-
Compilation
-
Interpretation
-
Execution
-
Debugging
D
Correct answer
Explanation
Debugging is the process of identifying and fixing errors in a program, typically involving testing the program, identifying the source of errors, and making necessary corrections.