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

Multiple choice
  1. from the point of definition onward in the program

  2. throughout the function

  3. from the point of definition onward in the function

  4. from the point of definition onward in the block

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

Multiple choice
  1. are a group of functions with the same name

  2. make life harder for programmers

  3. may fail unexpectedly due to over stress

  4. all have same number and type of arguments

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

Multiple choice
  1. returns a pointer to a variable

  2. creates a variable called new variable

  3. clears memory for a new variable

  4. tells how much memory is available

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

Multiple choice
  1. only from the innermost loop

  2. only from the innermost switch

  3. from the innermost loop or switch

  4. from all loops or switches

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

Multiple choice
  1. Try

  2. Catch

  3. Struct

  4. Throw

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

Multiple choice
  1. an operator

  2. a label

  3. a function

  4. a variable

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

The goto statement is an unconditional jump that transfers program control to a labeled statement within the same function.

Multiple choice
  1. the flow of control through a function

  2. a flow of data from one place to another

  3. not related to a class

  4. takes no arguments

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

Multiple choice
  1. Their storage is temporary.

  2. They hardly handle large amount of data.

  3. They have storage permanent.

  4. Both (1) and (2)

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

Variables and arrays are stored in volatile memory (temporary) and are not suitable for handling large, persistent datasets.

Multiple choice
  1. read from stream

  2. write to the stream

  3. both (1) and (2)

  4. none of these

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

Multiple choice
  1. mutable files

  2. Immutable files

  3. Transactions

  4. None of these

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

The all-or-nothing property, also known as atomicity, is a fundamental characteristic of transactions in database and distributed systems.