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
-
func_get_arg
-
func_get_args
-
func_num_args
-
none of these
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.
-
func_get_arg
-
func_get_args
-
func_num_args
-
none of these
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.
-
Assign
-
Include
-
List
-
All of the above
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.
-
array_funct
-
array_walk
-
array_apply
-
in_array
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.
-
require()
-
require_once()
-
both (1) and (2)
-
include
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.
-
call by value
-
call by reference
-
call by address
-
call by value result
-
default argument
B
Correct answer
Explanation
Call by reference mechanism uses another name of arguments.
-
deletes
-
hides
-
formats
-
shows
-
destroys
B
Correct answer
Explanation
Encapsulation feature of OOPs hides data from the user.
-
virtual function
-
function template
-
static funciton
-
friend function
-
inline function
B
Correct answer
Explanation
A function or group of functions that differ in the types of parameters they use is called function template.
-
Syntax tree
-
Symbol table
-
Set
-
Literal table
-
Queue
D
Correct answer
Explanation
This data structure of the compiler, stores constants and strings used in a program.
-
Semaphore
-
Indivisible operation
-
Critical section
-
Race condition
A
Correct answer
Explanation
Semaphore is a shared integer variable with non-negative values, which can only be subjected to initialization and invisible operations.
-
Thread
-
Program
-
Code files
-
None of these
C
Correct answer
Explanation
Code files can obtain a symbol table - a table indicating the names of all functions and global variables, and the virtual addresses that correspond to.
-
strcpy()
-
strlen()
-
strlwr()
-
strcat()
-
abs()
D
Correct answer
Explanation
This function is used to add/append the content of the source string into the content of the target string.
-
strcpy()
-
strlwr()
-
strlen()
-
getc()
-
strncpy()
E
Correct answer
Explanation
This string function is used to copy first n characters of one string to another string.
-
getc()
-
GET
-
fscanf()
-
ungetc()
-
ferror()
D
Correct answer
Explanation
This function pushes the character read previously using getc() back into input stream pointed to by the file pointer.
-
Address of operator
-
Size of operator
-
The comma operator
-
Increment operator
-
Scope resolution operator
E
Correct answer
Explanation
This operator is used in the context of closes and in providing a global scope for the variable.