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. the first line of the class

  2. the main function

  3. the first executable method of the class

  4. none of the above

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

In C++, the main() function is the designated entry point where program execution begins. The first line of a class is not executable code itself, and 'first executable method' is ambiguous since main() is a global function, not a class method.

Multiple choice
  1. same variable is accessed in called function

  2. new variable is accessed in called function

  3. new object is created in memory

  4. both (2) and (3)

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

When passing arguments by value, a new copy of the variable is created and a new object is allocated in memory for the called function. The original variable remains unchanged in the caller's scope, so both statements (2) and (3) about new variable access and new object creation are correct.

Multiple choice
  1. is initialized by constant

  2. is not initialized.

  3. does not exist in C language

  4. only takes 'int' values

  5. works like null pointer

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

A pointer which is not initialized in C, is known as Wild Pointer.

Multiple choice
  1. strspn();

  2. strnset();

  3. strnsetu();

  4. strdup();

  5. strncpyk();

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

This option is true because this function takes two arguments, and it returns the position of the string from where the source array doesn’t match with the target one. Format of this function is :-Strspn( string 1, string 2). For example, suppose we enter first string as “good morning” and second string as “good luck”. So, the function will return 5 because after 5 characters there is no match found in the strings. So, this is correct.

Multiple choice
  1. contains no data until a call for it is made

  2. is an object that is mapped to a SELECT sentence

  3. both (1) and (2)

  4. none of these

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

A VIEW is a virtual table based on the result-set of a SELECT query. It contains no stored data itself - data is generated dynamically when the view is queried. Option C correctly captures both characteristics: views don't store data (option A) and are mapped to SELECT statements (option B).

Multiple choice
  1. Assign NULL value to the next pointer field of the new node.

  2. Assign address of the new node to start.

  3. Both (1) & (2)

  4. None of these

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

Inserting at the end of a linked list involves two key steps: setting the new node's next pointer to NULL (since it will be the last element), and updating the previous last node's next pointer to point to the new node. Both operations are necessary to properly maintain list integrity.

Multiple choice
  1. .c

  2. .h

  3. .obj

  4. .exe

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

A compiler translates source code into object code, which is stored in object files (.obj on Windows, .o on Unix-like systems). These object files contain machine code but may not be fully linked - they may reference external symbols that the linker will resolve. The .exe file is produced by the linker, not the compiler.

Multiple choice
  1. Stack

  2. Queue

  3. Circular queue

  4. None of these

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

Stacks are fundamental to recursive expression evaluation in compilers. Each recursive call pushes a new activation record containing local variables and return addresses. The Last-In-First-Out (LIFO) nature of stacks matches the call-return pattern of recursion.