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
-
Only A
-
Only B
-
Both A and B
-
Neither A nor B
C
Correct answer
Explanation
We can always create a reference to an array and also reference is implicitly treated as constant pointer. Because reference to a particular variable cannot point to another variable.
-
Handle any exception that is not caught by other handlers
-
Handle all I/O exceptions
-
Handle all exceptions
-
None of these
A
Correct answer
Explanation
The ellipsis (...) is used by catch statement to handle all those exceptions that are not caught by other handlers.
A
Correct answer
Explanation
The member function get() is used to get a single character from a file. And put() is used to write a character to a file.
-
ios::in
-
ios::out
-
ios::app
-
ios::in | ios::out
D
Correct answer
Explanation
The default mode for a open() member function of fstream class is ios::in | ios::out.
-
cin and cout
-
printf and scanf
-
fprintf and fscanf
-
all of the above
A
Correct answer
Explanation
cin and cout set is the combination of format free input/output statement. Because here field width cannot be specified.
-
width()
-
fill()
-
setf()
-
nosetf()
D
Correct answer
Explanation
nosetf() is not a function in ios class.
-
a variable, the value of which keeps on changing through out the program
-
a variable, the value of which increase in a uniform order
-
a variable, the value of which decreases constantly
-
a variable, the value of which remains constant through out the program
D
Correct answer
Explanation
A static variable in C++ retains its value between function calls and is initialized only once. It exists for the entire program duration, maintaining its value throughout execution. Unlike automatic variables, static variables do not get re-initialized on each function call.
-
Postfix operators can appear only on the right side of the operand.
-
A postfix operator first changes the value of its operand before taking its value.
-
A postfix operator first fetches the value and then increments it.
-
Postfix operators cannot be overloaded.
C
Correct answer
Explanation
Postfix operators return the original value before applying the operation. For example, i++ in an expression returns the current value of i, then increments i afterward, unlike prefix operators that modify first.
-
Dynamic linking
-
Static linking
-
Static library
-
Shared library
B
Correct answer
Explanation
Static linking is used to combine multiple functions into a single executable module.
-
Normal exit
-
Error exit
-
Fatal error
-
None of these
D
Correct answer
Explanation
Fatal error is the error caused by process due to a bug in program for example, executing an illegal instruction.
-
Abstract syntax tree
-
Symbol table
-
Semantic stack
-
Parse table
B
Correct answer
Explanation
Symbol table is used for storing information about variables and their attributes by compiler.
-
Array
-
Union
-
Structure
-
Tokens
C
Correct answer
Explanation
Structure is a collection of logically related variables referenced under one name.
-
string.h
-
math.h
-
ctype.h
-
conio.h
C
Correct answer
Explanation
The function 'isdigit()' belongs to ctype.h function as it is the character type function used to check whether input data is digit or not.
-
Call by Reference
-
Call by Value
-
Global function
-
None of these
B
Correct answer
Explanation
This method of passing arguments to a function passes the copy of the arguments to the called function.
-
The stack pointer (SP) is used to hold the address of top of element of the stack.
-
A stack can be implemented in a random access memory (RAM) attached to a CPU.
-
A stack is incremented after fetching an instruction.
-
A stack can be arranged in a collection of registers.
-
None of the above
C
Correct answer
Explanation
This is a false statement as the Program Counter register is incremented on fetching of the instruction.