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. 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. S1 and S2

  2. S1 and S4

  3. S3

  4. S1 and S5

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

Multiple choice
  1. The code contains loop invariant computation

  2. There is scope of common sub-expression elimination in this code

  3. There is scope of strength reduction in this code

  4. There is scope of dead code elimination in this code

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

All the statements are true except option (4) since there is no dead code to get eliminated

Multiple choice
  1. The implementation may not work if context switching is disabled in P

  2. Instead of using fetch-and -set, a pair of normal load/store can be used

  3. The implementation of V is wrong

  4. The code does not implement a binary semaphore

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

If there are more than two processes and context & switching processes is disabled in P then this implementation doesn't work properly and can't synchronize the processes.

Multiple choice
  1. declaring a variable

  2. declaring an event

  3. naming convention

  4. none of the above

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

In Visual Basic, 'Dim' is the keyword used to declare variables. It stands for 'Dimension' and allocates memory storage for the variable. It is not used for declaring events or naming conventions.

Multiple choice
  1. general procedures

  2. variable declarations

  3. constant definitions

  4. all of these

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

A module in Visual Basic includes all of these: general procedures (subroutines and functions), variable declarations (at module level), and constant definitions. Modules are containers that hold related code and data declarations.

Multiple choice
  1. a string

  2. a variable

  3. square root of a number

  4. square of a number

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

The Sqr() function in Visual Basic returns the square root of a numeric value. For example, Sqr(16) returns 4. It is the inverse of the square operation.

Multiple choice
  1. Do While……..loop

  2. Do loop While…………

  3. For……….Next loop

  4. For Each …………Next Loop

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

In Do...Loop While, the statements execute first, then the condition is tested. This guarantees at least one execution, unlike Do While...Loop where the condition is tested before execution.

Multiple choice
  1. code line

  2. comment line

  3. loop statement

  4. none of these

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

The single quote (') character in Visual Basic indicates the start of a comment. All text following the quote on that line is ignored by the compiler and used for documentation.

Multiple choice
  1. Background Color

  2. Back Color

  3. BehindColor

  4. None of these

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

In Visual Basic, the property that controls a form's background color is called 'BackColor' (written as two words: Back and Color). This is the standard naming convention for color properties in VB controls. 'Background Color' and 'BehindColor' are not valid property names in VB.

Multiple choice
  1. It provides the assembly specific metadata for all the applications.

  2. It is responsible for the storage information of the data objects.

  3. It provides application specific classes and the methods.

  4. It manages the execution flow.

  5. It provides data storage capacity.

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

It does not manage any execution flow in the application.

Multiple choice
  1. break

  2. continue

  3. return

  4. none of these

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

A finally block executes regardless of how the try block exits (exception or normal completion). Control flow statements like break, continue, and return cause the finally block to execute before the transfer occurs, but they cannot appear inside the finally block itself.

Multiple choice
  1. CLR and Class Library

  2. CTS and CLR

  3. MSIL and CLR

  4. Class Library and CTS

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

CLR is Common Language Runtime, which distinguishes .NET framework from other frameworks as this makes .NET framework language independent and Class Library provides the collection of useful and reusable types that are designed to integrate with CLR.