Computer Knowledge
Programming Fundamentals
2,611 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
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.
-
A Type I error is rejecting the null hypothesis when it is true.
-
A Type I error is accepting the null hypothesis when it is false.
-
A Type I error is making a false positive decision.
-
A Type I error is making a false negative decision.
A
Correct answer
Explanation
A Type I error is rejecting the null hypothesis when it is true, also known as a false positive decision.
-
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.
Which of the following is a JavaScript data type?
-
String
-
Number
-
Boolean
-
All of the above
D
Correct answer
Explanation
JavaScript has three primitive data types: String, Number, and Boolean. It also has a special data type called null and a global object called undefined.
What is the significance of dependent types?
-
They enable more expressive type systems
-
They improve program verification techniques
-
They enhance the security of programming languages
-
They facilitate the development of type-safe libraries
A
Correct answer
Explanation
Dependent types allow for more precise and expressive type systems, enabling the representation of complex relationships between data.
What is the role of type inference in Type Theory?
-
To automatically determine the type of an expression
-
To verify the correctness of a program
-
To optimize the execution of a program
-
To generate test cases for a program
A
Correct answer
Explanation
Type inference in Type Theory is the process of automatically deducing the type of an expression based on its structure and the types of its components.
What is the correct syntax for declaring a variable in JavaScript?
-
var variableName;
-
let variableName;
-
const variableName;
-
All of the above
D
Correct answer
Explanation
In JavaScript, you can declare a variable using the var, let, or const keyword, followed by the variable name and a semicolon.
What is the difference between var, let, and const in JavaScript?
-
var is used for global variables, let is used for local variables, and const is used for constants.
-
var is used for variables that can be reassigned, let is used for variables that cannot be reassigned, and const is used for constants.
-
var is used for variables that are declared at the top of a function, let is used for variables that are declared within a block, and const is used for constants.
-
None of the above
Correct answer
Explanation
In JavaScript, let is used for variables that cannot be reassigned, and const is used for constants. var is used for variables that can be reassigned, but it is generally discouraged to use var in modern JavaScript code.
What is the correct syntax for creating a function in JavaScript?
-
function functionName() { ... }
-
const functionName = () => { ... }
-
let functionName = () => { ... }
-
All of the above
D
Correct answer
Explanation
In JavaScript, you can create a function using the function keyword, followed by the function name and parentheses. You can also create a function using an arrow function, which is a concise syntax for writing a function. Arrow functions can be written using the const or let keyword, followed by the arrow (=>) symbol and the function body.
What is the difference between a function declaration and a function expression in JavaScript?
-
A function declaration is hoisted to the top of the scope, while a function expression is not.
-
A function declaration can be called before it is defined, while a function expression cannot.
-
A function declaration can be used as a value, while a function expression cannot.
-
None of the above
A
Correct answer
Explanation
In JavaScript, a function declaration is hoisted to the top of the scope, which means that it can be called before it is defined. A function expression is not hoisted, so it cannot be called before it is defined.
What is the correct syntax for creating an array in JavaScript?
-
const arrayName = [];
-
let arrayName = [];
-
var arrayName = [];
-
All of the above
D
Correct answer
Explanation
In JavaScript, you can create an array using the const, let, or var keyword, followed by the array name and square brackets.
What is the correct syntax for creating an object in JavaScript?
-
const objectName = {};
-
let objectName = {};
-
var objectName = {};
-
All of the above
D
Correct answer
Explanation
In JavaScript, you can create an object using the const, let, or var keyword, followed by the object name and curly braces.