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
  1. It cannot have subroutine call instruction.

  2. It can have subroutine call instruction, but no nested subroutine calls.

  3. Nested subroutine calls are possible, but interrupts are not.

  4. All sequences of subroutine calls and also interrupts are possible.

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

Stack pointer register holds the address of top of stack, which is the location of memory at which the CPU should resume its execution after servicing some interrupt or subroutine call. So if SP register not available then no subroutine call instructions are possible.

Multiple choice
  1. At most one activation record exists between the current activation record and the activation record for the main.

  2. The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence.

  3. The visibility of global variables depends on the actual function calling sequence.

  4. Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive fraction can be called.

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

Activation record is the contiguous memory locations where the data needed by the program is kept so at most one activation record exist between current activation record & the record for the main.

Multiple choice
  1. I,II, and IV only

  2. II, III, and IV only

  3. II and IV only

  4. IV only

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation
int main(){
    int *A[10], B[10][10];
    int c[] = {12, 11, 13, 14};

   A[2] = C;

   A[2][3] = 15;

   B[2][3] = 15;

   printf("%d %d', A[2][0], A[2][3]);
   getchar();
}
Multiple choice
  1. call swap (x,y)

  2. call swap (&x,&y)

  3. swap (x,y) cannot be used as it does not return any value

  4. swap (x,y) cannot be used as the parameters are passed by value

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

Here the function takes the arguments by value.

$\rightarrow$       Option (A) sends parameter by value but only the local variable a & b will be exchanged but not the actual variables x & y so incorrect. $\rightarrow$ Option (B) is incorrect sending address of x & y . $\rightarrow$ Option (C) swap (x,y) is usable there is no need to return. $\rightarrow$ Option (D) is the opposite statement of option (A), it says that the values are passed by value so won't swap so the option is correct.

Multiple choice
  1. A function that takes an integer pointer as argument and returns an integer

  2. A function that takes an integer pointer as argument and returns an integer pointer

  3. A pointer to a function that takes an integer pointer as argument an returns

  4. A function that takes an integer pointer as argument returns a function pointer

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

Multiple choice
  1. always be evaluated

  2. be evaluated only if the definition is L-attributed

  3. be evaluated only if the definition has synthesized attributes

  4. never be evaluated

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

Every S (synthesized) -attributed definitions is L- attributed. So in a bottom-up evaluation of SDD inherited attributes can be evaluated only if the definition has synthesized attributes.

Multiple choice
  1. In statically typed languages, each variable in a program has a fixed type

  2. In un-typed languages, values do not have any types

  3. In dynamically typed languages, variables have no types

  4. In all statically typed languages, each variable in a program is associated with values of only a single type during the execution of the program

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

(1) True for statically typed languages where each variable has fixed type. Similarly (4) is also correct. (2) True, in un-typed languages types of values are not defined. But option (3) is false, since in dynamically typed language variables have dynamically changing types but not that they have no type.

Multiple choice
  1. 115, 220

  2. 25, 220

  3. 25, 15

  4. 115, 105

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

Multiple choice
  1. 115, 220

  2. 25, 220

  3. 25, 15

  4. 115, 105

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

Multiple choice
  1. Smaller sizes of executable files

  2. Lesser overall page fault rate in the system

  3. Faster program startup

  4. Existing programs need not be re-linked to take advantage of newer versions of libraries

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

The advantages of shared dynamically linked libraries include. (1) smaller size of executable since less data (2) lesser overall page fault rate. (3) No need for re-linking if newer versions of libraries are there. But since compilation time doesn't include linking so a long linking time required during runtime in DLL' s so slow startup.

Multiple choice
  1. X = Y + Z

  2. t1 = Y + Z; X = t1

  3. t1 = Y; t2 = t1 + Z; X = t2

  4. t1 = Y; t2 = Z; t3 = t1 + t2; X = t3

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

Multiple choice
  1. II and V only

  2. I, III and IV only

  3. I, II and V only

  4. II, III and V only

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