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 technology programming languages
  1. Page length of a particular output file

  2. The input end-of-line character

  3. The return code returned by a command called by the system function.

  4. The error code generated by a system library routine

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

In Perl, the special variable $? contains the status (return code) of the last external command executed, typically through system(), backticks, or piped opens. It is not for page length, EOL characters, or library error codes. The value is 0 for successful execution and non-zero for errors, following Unix conventions.

Multiple choice technology programming languages
  1. Page length of a particular output file

  2. The input end-of-line character

  3. The return code returned by a command called by the system function.

  4. The error code generated by a system library routine.

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

In Perl, the special variable $! contains the current value of errno (the error code from a system library routine) when a system call fails. It provides both numeric error code in numeric context and descriptive error string in string context. It is not for page length, EOL characters, or command return codes (which is $?).

Multiple choice technology programming languages
  1. splice (@array,0.0.@sublist);

  2. splice (@array, scalar(@array),0, @sublist);

  3. splice (@array, 1, 0, @sublist);

  4. None of Above

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

The splice function can replace push when used with the current array size as the starting position. By setting the offset to scalar(@array) (the end of the array), length to 0 (nothing removed), and providing @sublist as the elements to insert, splice behaves exactly like push - appending elements to the array's end.

Multiple choice technology programming languages
  1. hash

  2. noexit

  3. nozero

  4. die

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

The die function in Perl terminates program execution with a nonzero exit status and outputs an error message to standard error. This makes it the appropriate choice for ensuring your program indicates failure through its exit code, even when errors occur during execution.

Multiple choice technology programming languages
  1. var left-shifted 2 bits

  2. var mutliplied by 2 bits

  3. var reduced 2 bits

  4. None of the above

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

The <<= operator in Bash arithmetic evaluation (let) is the left-shift assignment operator. It shifts the bits of var to the left by 2 positions and assigns the result back to var. This is equivalent to multiplying by 4, not 'multiplied by 2 bits' or 'reduced'.

Multiple choice technology programming languages
  1. ALL , AUTOMATIC , USER

  2. AUTO , SYS , LOCAL

  3. ALL , LOCAL ,USERDEFINED

  4. ALL , AUTO , GLOBAL

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

In SAS, the %put statement supports specific keywords to list macro variables in the log. _ALL_ displays all variables, _AUTOMATIC_ displays SAS-defined automatic variables, and _USER_ displays user-defined variables. Other options contain invalid keywords like _AUTO_ or _USERDEFINED_.

Multiple choice technology programming languages
  1. Referencing a nonexistent macro variable results in a warning message. Referencing an invalid macro variable name results in an error message.

  2. Referencing a nonexistent macro variable results in a error message. Referencing an invalid macro variable name results in an warning message.

  3. Referencing a nonexistent macro variable and invalid macro variable name results in an error message.

  4. Referencing a nonexistent macro variable and invalid macro variable name results in an warning message.

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

In SAS, referencing a nonexistent macro variable generates a warning in the log, and the reference is left unresolved. However, referencing an invalid macro variable name (which violates SAS naming rules, such as starting with a number) violates syntax rules and results in a compilation error.