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 mainframe
  1. MAPFAIL

  2. ASRA

  3. ASRB

  4. AEI9

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

In CICS MAPFAIL is the error condition when a user presses Enter without entering any value in a map field. This is a CICS-specific exception that occurs when the map receives no input data. The other options (ASRA, ASRB, AEI9) are different CICS abend codes - ASRA is a program check, ASRB is a transaction abend, and AEI9 is an invalid EXEC CICS command.

Multiple choice technology operating systems
  1. 1 True

  2. 2 False

  3. 3

  4. 4

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

A zombie process is a terminated process whose entry remains in the process table. If the parent dies without reaping the child, the child is adopted by 'init' (PID 1), which then reaps it, but the zombie state itself refers to the period before reaping.

Multiple choice technology operating systems
  1. 1 getenv(), setenv()

  2. 2 getenv(), putenv()

  3. 3 readenv(), writeenv()

  4. 4 You cannot environmement variables inside a program

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

getenv() retrieves the value of an environment variable, and putenv() changes or adds an environment variable to the current environment. setenv() is not part of standard C (though it exists as a BSD/gnu extension), and readenv()/writeenv() do not exist.

Multiple choice technology programming languages
  1. a. String str[];

  2. b. String str[5] = new String[5];

  3. c. String str[] = new String[] {"string1", "string2", "string3", "string4", "string5

  4. d. String str[] = {"string1","string2", "string3", "string4", "string5"};

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

Option A is a valid declaration. Option C and D are valid initializations. Option B is invalid because you cannot specify the array dimension on the left side of the assignment in Java.

Multiple choice technology
  1. Compilation error

  2. You are well versed!

  3. versed!

  4. You are well

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

The Perl print statement outputs the string "You are well versed!" followed by a newline character "\n". The semicolon terminates the statement. Perl's print function simply outputs the given string to STDOUT. Options C and D would only be true if we were using substring operations or different string splitting functions.

Multiple choice technology
  1. True

  2. cap

  3. able

  4. compilation error

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

The regex match operator =~ in Perl returns true if the pattern matches the string. The pattern /able/ is found in "Capable", so the match succeeds and returns true (which evaluates to 1 in boolean context). Option B 'cap' is not the return value, option C 'able' is just the matched substring, and option D is incorrect because this is valid Perl syntax.

Multiple choice technology security
  1. Replace cin call in line 3 with gets() function

  2. The length of input from cin cannot be limited. Use a larger array for fname

  3. Use cin.width[20] before line 3

  4. Use cin.size[19] before line 3

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

The 'cin >>' operator is unbounded and can cause buffer overflows. Using 'cin.width(n)' or the 'setw(n)' manipulator limits the number of characters read into the buffer, ensuring it does not exceed the array size.

Multiple choice technology security
  1. No vulnerabilities are present

  2. Line 1 should only use malloc(inputsize)

  3. Line 2 should be for (i=0; i<=n, i++)

  4. Line 1 should use calloc() instead of malloc()

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

The code uses uninitialized memory from malloc(). Using += on uninitialized values reads garbage values. calloc() zero-initializes memory, which is the safe approach. Option B would allocate insufficient space, option C would cause an out-of-bounds access, and option A is incorrect - there is a vulnerability.

Multiple choice technology databases
  1. Exception

  2. Executable

  3. Declarative

  4. Anonymous

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

The Executable section of a PL/SQL block contains the procedural code and starts with the BEGIN keyword. The Exception section (EXCEPTION) handles errors, the Declarative section (DECLARE) defines variables and types, and Anonymous is not a section name but a block type.

Multiple choice technology security
  1. Integer overflow

  2. Buffer overflow

  3. Stack overflow

  4. Data type mismatch

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

Adding two unsigned integers can cause integer overflow if the sum exceeds the maximum value of the unsigned int type. The result will wrap around modulo 2^32 (on 32-bit systems), producing an incorrect total. This is a classic integer overflow vulnerability in C.

Multiple choice technology security
  1. /GS on Visual C++ and -fmudflap -fmudflapth -fmudflapir on GCC

  2. /O in Vc++ and -O2 in GCC

  3. /S in Vc++ and -fcrossjumping in GCC

  4. /S in VC++ and -fno-function-cse in GCC

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

/GS in Visual C++ enables buffer security checks (stack canaries), and GCC's -fmudflap options provide runtime buffer overflow protection. Option A correctly identifies both. Options B, C, D list optimization or unrelated flags that do not protect against buffer overflows.

Multiple choice technology security
  1. SQL Injection

  2. Arc Injection

  3. Buffer Overflow

  4. both 2 and 3

Reveal answer Fill a bubble to check yourself
C Correct answer