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 general knowledge science & technology
  1. is a true random number generator.

  2. returns positive double values.

  3. is a pseudo-random number generator.

  4. returns a different sequence of values each time it is run.

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

rand() is a pseudo-random number generator - it uses an algorithm to produce seemingly random numbers from a seed value. It produces the same sequence unless seeded with srand(). True randomness requires hardware entropy sources.

Multiple choice general knowledge science & technology
  1. the first value in the range of numbers.

  2. the last value in the range of numbers.

  3. the number of terms in the range of numbers.

  4. the number of guesses the user will be allowed.

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

In the formula a + rand() % n, the modulo operation ensures the result ranges from 0 to n-1. So n represents the count of possible values. Adding a shifts the range to [a, a+n-1].

Multiple choice general knowledge science & technology
  1. Subroutine

  2. Compile

  3. Null pointer

  4. Interleave

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

The question asks which term is NOT related to programming. 'Subroutine', 'Compile', and 'Null pointer' are all fundamental programming concepts. 'Interleave' is primarily a term from electronics (interleaving memory) or mathematics (interleaving sequences), not a core programming concept. While interleaving can be used in some programming contexts (like data organization), it's not fundamentally a programming term like the others.

Multiple choice general knowledge science & technology
  1. append(*p,cry,cop);

  2. append(&p,cry,cop);

  3. append(**p,cry,cop);

  4. append(p,cry,cop);

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

The append function takes a double pointer (struct vg **q) to modify the head pointer. When calling from main with p (a single pointer), we must pass &p to match the double pointer parameter. Option B does this correctly.

Multiple choice general knowledge science & technology
  1. True

  2. False

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

Multiple compilation errors: is_exist uses undefined variable 'n' (should be temp), uses undefined type 'boolean', and the result variable 'result' is never returned. The function tries to malloc a struct node instead of struct vg.

Multiple choice general knowledge
  1. True

  2. False

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

In object-oriented programming (like Java or C++), a constructor is a special method used to initialize objects. It does not have a return type, not even 'void', and therefore never returns a value.

Multiple choice general knowledge
  1. Shift+Alt+s, then t

  2. Shift+Alt+s, then g

  3. Shift + Alt + s, then r

  4. Shift+Alt+s, then c

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

Alt+Shift+S followed by R opens the Generate Getters and Setters dialog in Eclipse. The 'S' stands for Source menu, and 'R' triggers the getter/setter generation option from that menu.

Multiple choice general knowledge
  1. parseInt()

  2. exec()

  3. eval()

  4. parseFloat()

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

exec() is a method of RegExp objects, not a global built-in function. parseInt(), eval(), and parseFloat() are all global functions available without any object prefix. The exec() method must be called on a RegExp instance and returns match information for a regular expression test.

Multiple choice general knowledge
  1. new

  2. this

  3. delete

  4. typeof

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

'this' is a keyword that refers to the current execution context, not an operator. The new operator creates object instances, delete removes properties, and typeof returns a string indicating the operand's type. These are all JavaScript operators, but 'this' is a contextual keyword.

Multiple choice general knowledge
  1. Function declared static in the file1.c can access the variable

  2. All the functions in the file1.c can access the variable

  3. None of the options

  4. No function in file1.c can have access

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

A static variable at file scope (outside any function) has internal linkage - it's visible to all functions in the same file but not to other files. Option B correctly states that all functions in file1.c can access it. Option A is incorrect because there's no requirement for functions to be declared static.

Multiple choice general knowledge science & technology
  1. Checked

  2. Sealed

  3. ReadOnly

  4. Fixed

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

The 'fixed' statement in C# pins a managed variable in memory so the garbage collector cannot relocate it during pointer operations. This is essential when working with unsafe code and pointers, as moving the object would invalidate the pointer address. Checked is for overflow arithmetic, Sealed prevents inheritance, and ReadOnly allows only initialization.

Multiple choice general knowledge
  1. Debugging

  2. Compiling

  3. Interpreting

  4. None of these

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

Debugging is the process of identifying, isolating, and fixing errors or bugs in computer programs. Compiling translates code, interpreting executes code line-by-line, but only debugging specifically deals with error correction.