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. func_get_arg

  2. func_get_args

  3. func_num_args

  4. none of these

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

func_get_args() returns an array containing all arguments passed to the current function. This is useful for variable-length argument lists. Related functions: func_num_args() returns count, func_get_arg(n) returns single argument at position n.

Multiple choice
  1. func_get_arg

  2. func_get_args

  3. func_num_args

  4. none of these

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

func_num_args() returns the total number of arguments passed to a user-defined function. Unlike func_get_arg() (which gets a specific argument by index) or func_get_args() (which returns the entire array of arguments), this function only returns the count.

Multiple choice
  1. Assign

  2. Include

  3. List

  4. All of the above

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

The list() construct in PHP assigns array elements to variables in a single operation, treating the array values as if they were being assigned to individual variables. It's commonly used with arrays that have numeric indices. For example: list($a, $b) = array(1, 2) assigns 1 to $a and 2 to $b.

Multiple choice
  1. array_funct

  2. array_walk

  3. array_apply

  4. in_array

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

array_walk() applies a user-defined callback function to each element of an array. This is useful for performing operations on every array element, such as formatting, validation, or transformation. The callback function receives the element's value and optionally its key and index.

Multiple choice
  1. require()

  2. require_once()

  3. both (1) and (2)

  4. include

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

Both require() and require_once() cause fatal errors and terminate the script if the included file cannot be found or cannot be opened. This is different from include() and include_once(), which only generate warnings and allow the script to continue. The '_once' variants ensure the file is included only once even if called multiple times.