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
-
from the point of definition onward in the program
-
throughout the function
-
from the point of definition onward in the function
-
from the point of definition onward in the block
D
Correct answer
Explanation
In C++, a variable defined within a block (enclosed by curly braces) has block scope. It is only accessible from the point of its declaration until the end of that specific block.
-
are a group of functions with the same name
-
make life harder for programmers
-
may fail unexpectedly due to over stress
-
all have same number and type of arguments
A
Correct answer
Explanation
Function overloading allows multiple functions to share the same name provided they have different parameter lists (different number or types of arguments). This improves code readability and reuse.
-
returns a pointer to a variable
-
creates a variable called new variable
-
clears memory for a new variable
-
tells how much memory is available
A
Correct answer
Explanation
The 'new' operator in C++ allocates memory dynamically on the heap and returns the address of the allocated memory, which is stored in a pointer variable.
-
only from the innermost loop
-
only from the innermost switch
-
from the innermost loop or switch
-
from all loops or switches
C
Correct answer
Explanation
The 'break' statement is used to terminate the execution of the nearest enclosing loop (for, while, do-while) or switch statement. It does not exit nested loops or switches beyond the immediate one.
-
synchronous exceptions
-
asynchronous exceptions
-
all of above
-
none of these
B
Correct answer
Explanation
Asynchronous exceptions are caused by events external to the program, such as hardware interrupts or user input, which the program cannot predict or control directly.
D
Correct answer
Explanation
In C++, the throw keyword is used to signal that an exception has occurred. Try and catch are used to handle the exception, while struct is a data structure definition.
-
keywords
-
constants
-
tokens
-
operators
A
Correct answer
Explanation
Keywords are reserved words in a programming language that have a predefined meaning and cannot be used as identifiers for variables, functions, or classes.
-
an operator
-
a label
-
a function
-
a variable
B
Correct answer
Explanation
The goto statement is an unconditional jump that transfers program control to a labeled statement within the same function.
-
the flow of control through a function
-
a flow of data from one place to another
-
not related to a class
-
takes no arguments
B
Correct answer
Explanation
In C++, a stream is an abstraction that represents a device on which input and output operations are performed. It acts as a flow of data between a source and a destination.
-
password
-
pointer
-
picture
-
overlay
-
None of these
C
Correct answer
Explanation
In COBOL, the PICTURE clause is used to define the format, length, and data type (numeric, alphabetic, etc.) of a data item.
-
Their storage is temporary.
-
They hardly handle large amount of data.
-
They have storage permanent.
-
Both (1) and (2)
D
Correct answer
Explanation
Variables and arrays are stored in volatile memory (temporary) and are not suitable for handling large, persistent datasets.
-
read from stream
-
write to the stream
-
both (1) and (2)
-
none of these
C
Correct answer
Explanation
Filter streams in Java are designed to wrap existing streams to provide additional functionality, such as buffering or data transformation. They can perform these filtering operations on data as it is being read from or written to the underlying stream.
-
position dependent
-
position independent
-
location dependent
-
none of these
B
Correct answer
Explanation
Position-independent code (PIC) is machine code that executes correctly regardless of its absolute address in memory, which is essential for shared libraries.
-
Static
-
Dynamic
-
Both 1 and 2
-
None of these
B
Correct answer
Explanation
Dynamic relocation is performed at runtime, meaning the address mapping can change while the process is running.
-
mutable files
-
Immutable files
-
Transactions
-
None of these
C
Correct answer
Explanation
The all-or-nothing property, also known as atomicity, is a fundamental characteristic of transactions in database and distributed systems.