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

Multiple choice

What is the most common type of buffer overflow vulnerability?

  1. Stack overflow

  2. Heap overflow

  3. Format string overflow

  4. Integer overflow

Reveal answer Fill a bubble to check yourself
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.

Multiple choice

Which of the following is not a common type of error?

  1. Syntax errors

  2. Runtime errors

  3. Logical errors

  4. User errors

Reveal answer Fill a bubble to check yourself
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.

Multiple choice

Which of the following is not a common error-handling technique?

  1. Try-catch blocks

  2. Throw statements

  3. Assert statements

  4. Ignore errors

Reveal answer Fill a bubble to check yourself
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.

Multiple choice

Which of the following is not a common type of user error?

  1. Mistyping

  2. Misunderstanding the instructions

  3. Entering invalid data

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Mistyping, misunderstanding the instructions, and entering invalid data are all common types of user errors.

Multiple choice

What is the best way to handle errors that occur in a process?

  1. Use a try-catch block

  2. Use a throw statement

  3. Use an assert statement

  4. All of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The best way to handle errors that occur in a process is to use a try-catch block.

Multiple choice

Which of the following is a common type of error in quantum programs?

  1. Syntax errors

  2. Logical errors

  3. Runtime errors

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Common types of errors in quantum programs include syntax errors, logical errors, and runtime errors.

Multiple choice

What is the primary data structure used in NumPy for representing matrices?

  1. ndarray

  2. list

  3. tuple

  4. dictionary

Reveal answer Fill a bubble to check yourself
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.

Multiple choice

What is the primary data structure used in Eigen for representing matrices?

  1. MatrixXd

  2. VectorXd

  3. ArrayXd

  4. TensorXd

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Eigen, MatrixXd is the primary data structure for representing dense matrices, providing efficient access and manipulation of matrix elements.

Multiple choice

What is the primary data structure used in Julia's LinearAlgebra package for representing matrices?

  1. Matrix

  2. Vector

  3. Array

  4. DataFrame

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Julia's LinearAlgebra package, the Matrix data structure is used to represent matrices, offering efficient operations and manipulation.

Multiple choice

What is the primary data structure used in MATLAB for representing matrices?

  1. matrix

  2. array

  3. vector

  4. table

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In MATLAB, the matrix data structure is used to represent matrices, enabling efficient operations and manipulation of matrix elements.

Multiple choice

What is the primary data structure used in R's Matrix package for representing matrices?

  1. matrix

  2. array

  3. vector

  4. data.frame

Reveal answer Fill a bubble to check yourself
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.

Multiple choice

What is a Type II error?

  1. A Type II error is rejecting the null hypothesis when it is false.

  2. A Type II error is accepting the null hypothesis when it is true.

  3. A Type II error is making a false positive decision.

  4. A Type II error is making a false negative decision.

Reveal answer Fill a bubble to check yourself
Correct answer
Explanation

A Type II error is accepting the null hypothesis when it is false, also known as a false negative decision.

Multiple choice

What is the purpose of a loop in programming?

  1. To execute a block of code repeatedly

  2. To store data in memory

  3. To compare values and make decisions

  4. To input and output data

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A loop in programming allows a block of code to be executed repeatedly until a certain condition is met.

Multiple choice

What is the purpose of a variable in programming?

  1. To store data temporarily

  2. To perform calculations

  3. To control the flow of a program

  4. To input and output data

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A variable in programming is used to store data temporarily, allowing it to be accessed and modified throughout the program.

Multiple choice

What is the process of identifying and fixing errors in a program called?

  1. Compilation

  2. Interpretation

  3. Execution

  4. Debugging

Reveal answer Fill a bubble to check yourself
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.