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. This technique uses DEP for the control of execution flow.

  2. It occurs when structured exception handler begins to gracefully close an application.

  3. It occurs due to improper coding techniques.

  4. In this exploit, the attackers goal is to control a crash and gain code execution on the given system.

  5. It is not an exploit during Penetration test.

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

In ROP, during a portion where the user has control of execution flow however data execution prevention (DEP) or other precluding defense mechanisms may be in place.

Multiple choice
  1. does not permit IF-THEN GOTO statement

  2. may have all the program statements that have a single entry point and a single exit point

  3. both (1) and (2)

  4. neither (1) nor (2)

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

Structured programming languages minimize or eliminate GOTO statements in favor of control structures like if-then-else and loops. They emphasize single entry and exit points for program blocks to improve code readability and maintainability. Both statements correctly describe key principles of structured programming.

Multiple choice
  1. Loops

  2. GOTO statements

  3. Do-While statements

  4. All of the above

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

Structured programming is a programming paradigm that aims to improve code clarity and quality by reducing the use of GOTO statements. Instead, it uses control structures like loops (for, while), conditionals (if-then-else), and subroutines. The absence of GOTO statements is a defining characteristic of structured programming.

Multiple choice
  1. Accessing a variable that is declared but not initialized

  2. Accessing a storage that is already disposed at the request of the processor

  3. Accessing a storage that is already disposed at the request of the user

  4. All of the above

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

All of the above

Multiple choice
  1. go_cart

  2. go4it

  3. 4season

  4. run4

  5. what

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

In C, variable names must start with a letter or underscore, not a digit. '4season' begins with 4, making it invalid. 'go_cart', 'go4it', 'run4', and 'what' are all valid as they start with letters and contain only alphanumeric characters/underscores.

Multiple choice
  1. They are always 32-bit values.

  2. For efficiency, pointer values are always stored in machine registers.

  3. With the exception of generic pointers, similarly typed pointers may be subtracted from each other.

  4. A pointer to one type may not be cast to a pointer to any other type.

  5. With the exception of generic pointers, similarly typed pointers may be added to each other.

Reveal answer Fill a bubble to check yourself
E Correct answer
Multiple choice
  1. The variable's value.

  2. The variable's binary form.

  3. The variable's address.

  4. The variable's format.

  5. The variable's right value.

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

The unary & operator in C, when applied to a variable, returns the memory address of that variable. This is used for pointer operations and passing references to functions. Option A is incorrect because the variable's value is obtained by simply using the variable name. Option B describes a nonexistent operation. Option D and E are not valid C concepts.

Multiple choice
  1. The global variable is referenced via the extern specifier.

  2. The global variable is referenced via the auto specifier.

  3. The global variable is referenced via the global specifier.

  4. The global variable is referenced via the pointer specifier.

  5. The global variable is referenced via the ext specifier.

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

To access a global variable defined in another file, you must declare it with the extern specifier, which tells the compiler the variable exists elsewhere. The extern declaration doesn't allocate storage, it just references the existing definition. Option B is wrong because auto is for local variables. Option C and D are not valid specifiers. Option E uses an invalid specifier name.

Multiple choice
  1. X() effectively rounds f to the nearest integer value, which it returns.

  2. X() effectively performs a standard typecast and converts f to a roughly equivalent integer.

  3. X() preserves the bit-pattern of f, which it returns as an unsigned integer of equal size.

  4. Since u.n is never initialized, X() returns an undefined value. This function is therefore a primitive pseudo random number generator.

  5. Since u.n is automatically initialized to zero (0) by the compiler, X() is an obtuse way of always obtaining a zero (0) value.

Reveal answer Fill a bubble to check yourself
A Correct answer
Multiple choice
  1. *p++ causes p to be incremented before the reference is performed because both operators have equal precedence and are right associative.

  2. An array is a non-modifiable value, so p cannot be incremented directly. A navigation pointer should be used in conjunction with p.

  3. *p++ causes p to be incremented before the dereference is performed, because the auto-increment operator has higher precedence than the indirection operator.

  4. The condition of a while loop must be a Boolean expression. The condition should be n != 0.

  5. An array cannot be initialized to a variable size. The subscript n should be removed from the definition of the parameter p.

Reveal answer Fill a bubble to check yourself
E Correct answer