Computer Knowledge

Programming Fundamentals

2,381 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 technology programming languages
  1. True

  2. False

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

This declaration is incorrect because struct date contains a member 'year' of type 'date', which would create infinite recursion. A struct cannot contain a member of its own type (only pointers to itself are allowed).

Multiple choice technology programming languages
  1. Inline functions

  2. virtual functions

  3. Both A and B

  4. None of the Above

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

Inline functions are expanded at the call site, meaning the function body code is inserted directly where called rather than using a function call mechanism. This is done to eliminate function call overhead.

Multiple choice technology programming languages
  1. It resembles the header Of the function definition

  2. It tells the compiler the Names of the parameters

  3. It must be declared before its corresponding functions can be utilized

  4. All the above are incorrect

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

A function prototype informs the compiler about the function's interface (return type, parameters) so it can be verified before the full function definition is encountered. Since it declares the function, it must be declared before any utilization. Other options are correct descriptors of prototypes, making the choice of only one valid option slightly ambiguous, but the marked option is technically true.

Multiple choice technology programming languages
  1. Syntax Error

  2. Linker Error

  3. Runtme Error

  4. No Error, It will be run successfully

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

The code declares a function prototype int GetSquareOfx(int) but never provides the function definition. When the linker tries to resolve the function call GetSquareOfx(), it fails because the definition is missing. This produces a linker error (undefined reference), not a syntax error (which would be caught during compilation).

Multiple choice technology programming languages
  1. const

  2. volatile

  3. mutable

  4. All the Above

  5. None of the Above

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

const, volatile, and mutable are all storage qualifiers (cv-qualifiers) in C++. const indicates the value cannot be modified, volatile tells the compiler the value may change in ways not visible to the compiler (prevents optimization), and mutable allows a member variable to be modified even in a const member function.

Multiple choice technology programming languages
  1. static variables

  2. register variables

  3. global variables

  4. None of the Above

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

External variables in C++ are variables declared outside any function, making them accessible across multiple source files. These are commonly called global variables. Static variables have internal linkage (visible only within the file), and register variables are a hint to store variables in CPU registers (mostly obsolete in modern compilers).

Multiple choice technology programming languages
  1. True

  2. False

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

The struct contains a member 'date year' of its own type 'struct date', which creates a circular definition. C structs cannot contain members of their own type directly (only pointers). This would cause compilation error.

Multiple choice technology programming languages
  1. call by value

  2. call by reference

  3. call by address

  4. All the Above

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

When you pass pointers to a function, the function receives the address of the original variable. The function can access and modify the original data through that address. Call by value copies the actual parameter, call by address means passing pointers explicitly.

Multiple choice technology programming languages
  1. Inline functions

  2. virtual functions

  3. Both A and B

  4. None of the Above

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

An inline function suggests to the compiler that the function's code should be inserted directly at the point of call to eliminate function call overhead. Virtual functions support dynamic dispatch instead of inline substitution, and the other options are incorrect.

Multiple choice technology databases
  1. True

  2. False

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

ENUM values are stored as strings in the database, not as their underlying index numbers. While ENUM types do have an internal numeric index (1, 2, 3...), the actual storage uses the string representation. This is why ALTER TABLE can add new ENUM values without affecting existing data; the string value is what's persisted.