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
-
1 time
-
2 time
-
3 time
-
4 time
-
5 time
D
Correct answer
Explanation
This is the correct option as value of x becomes equal to value of y after 4 iteration. When both x and y values become equal to '0'.
-
To execute value of control variable multiple times.
-
To read value for one-dimensional array statement.
-
To execute value of outer variable to specified number of times in the inner loop.
-
To get sum and average of 'N' numbers.
-
To compare two strings.
C
Correct answer
Explanation
This is the correct option as in the nested loop statement inner loop is repeated specified number of times for each value of control variable in the outer loop.
-
while statement
-
do-while statement
-
for statement
-
switch statement
-
Nested for statement
D
Correct answer
Explanation
This is the correct option as 'continue' statement is used to skip the current iteration and continue with the next iteration in a program statement.
-
When we do not know the initial value for loop index variable.
-
When we know value for loop index variable.
-
When there is no test condition in the loop.
-
When there is test condition in the beginning of the loop.
-
When there is no increment statement in the loop.
A
Correct answer
Explanation
This is the correct reason to make use of do-while loop in a program as the condition is verified at the end in do-while loop.
-
Debugger
-
Control statement
-
Exception
-
Breakpoint
-
Stack trace
D
Correct answer
Explanation
In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes.More generally, a breakpoint is a means of acquiring knowledge about a program during its execution. During the interruption, the programmer inspects the test environment (general purpose registers, memory, logs, files, etc.) to find out whether the program is functioning as expected. In practice, a breakpoint consists of one or more conditions that determine when a program's execution should be interrupted.
-
u = x + 10 and v = y
-
u = x + 10 and v $\ne$ y
-
u + 10= x and v = y
-
u + 10 = x and v $\ne$ y
D
Correct answer
Explanation
Initial value of a is 10 and its address and the value of 'a' would be different for both the parent and child processes. So, (1) and (2) are incorrect. Also, parent process executes a = a − 5 = 5 = u and child executes a = a + 5 = 15 = x. Therefore, u + 10 = x.
-
Step 1 to step 5
-
Step 2 to step 5
-
Step 3 to step 5
-
Step 4 and step 5 only
-
Step 5 only
A
Correct answer
Explanation
When a page fault occurs, we have to restart the whole instruction from the instruction fetch step.
-
stack
-
queue
-
subroutine linkage
-
immediate addressing mode
-
lists
C
Correct answer
Explanation
This is a method in which a computer makes it possible to call and return values from subroutines.
D
Correct answer
Explanation
The 'try' block can throw an exception. The catch block catches and processes the exception.
-
compile time error
-
runtime error
-
infinite loop
-
none of these
B
Correct answer
Explanation
An exception is an unwanted event that occurs during runtime and terminates the execution. Hence, an exception is nothing but a runtime error.
-
Wrongly written inbuilt function
-
Divide by zero error
-
Array out of index error
-
File not found error
A
Correct answer
Explanation
Wrongly written inbuilt function gives the error in compile time. All the rest are runtime errors.
-
Modify
-
Mute
-
Mutable
-
Change
C
Correct answer
Explanation
When the member variable is declared as a mutable, any constant function can modify the data items , i.e. it is declared as mutable.
D
Correct answer
Explanation
The correct sequence of statements to handle an error is
- Hit the exception
- Throw the exception
- Catch the exception
- Handle the exception
-
cast_const
-
no_const
-
non_const
-
const_cast
D
Correct answer
Explanation
The const_cast can be used to convert a constant to non-constant. It can also be used to convert the data member of a class from the const functions.
-
Only A
-
Only B
-
Both A and B
-
Neither A nor B
A
Correct answer
Explanation
There will be a multiple catch clause with one try block. The catch block not only catches the exception but it also processes the exception.