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 causes a server control to perform final clean up.

  2. It checks the accessibility of the object.

  3. It is used to search a container for a specified control.

  4. This method is fired when the control is loaded in the page.

  5. This method is loaded when the data is retrieved.

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

It is the task of Load method.

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

Multiple choice
  1. Only I

  2. Both I and II

  3. Both II and III

  4. Only IV

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

Multiple choice
  1. q = NULL; p->next = head; head = p;

  2. q->next = NULL; head = p; p->next = head;

  3. head = p; p->next = q; q->next = NULL;

  4. q->next = NULL; p->next = head; head = p;

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

Multiple choice
  1. 2

  2. 3

  3. 4

  4. 6

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

This is a register allocation problem using graph coloring principles. Tracking live variables: a=1 (a live), b=10 (a,b), c=20 (a,b,c), d=a+b (b,c,d) - a dead, e=c+d (c,d,e) - b dead, f=c+e (c,e,f) - d dead, b=c+e (b,c,e,f), e=b+f (b,e,f) - c dead, d=5+e (d,e,f) - b dead, return d+f (d,f). At the end, we need d and f alive simultaneously. Minimum registers needed = 3. We can allocate: R1=e (then f), R2=c (through multiple uses), R3=d (final). This satisfies all constraints with 3 registers. With only 2 registers, we'd need to spill a variable.

Multiple choice
  1. getpid

  2. fork

  3. ioctl

  4. open

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

The getpid system call retrieves the process ID of the calling process, which always succeeds and thus never returns an error. In contrast, fork, ioctl, and open can all fail under various system conditions such as resource exhaustion or invalid arguments.

Multiple choice
  1. 1,2,3,4

  2. 1, 2

  3. 2, 3, 4

  4. 3, 4

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

CFL’s are not closed under complementation. Regular and recursive languages are closed under complementation.

Multiple choice
  1. fails as L can overflow

  2. fails as L can take on a non-zero value when the lock is actually available

  3. works correctly but may starve some processes

  4. works correctly without starvation

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

Multiple choice
  1. 0

  2. 1

  3. 2

  4. 3

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

In the above code, total number of spills to memory is 2.