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
  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. 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. array

  2. constant

  3. integer

  4. double

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

In Visual Basic, the 'To' keyword is used in array declarations to specify a range, like 'Dim arr(1 To 10) As Integer'. This creates an array indexed from 1 to 10. The other options (constant, integer, double) use different declaration syntax without the 'To' keyword.

Multiple choice
  1. private

  2. public

  3. static

  4. dim

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

The 'Public' keyword declares a variable with global scope, making it accessible from anywhere in the program (across different modules and forms). Private limits scope to its own module, static preserves values between calls, and dim creates local variables. Public enables program-wide availability.

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. boolean

  2. integer

  3. string

  4. variant

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

The default datatype in Visual Basic is Variant. A Variant can hold any type of data (numbers, strings, dates, etc.) and VB automatically converts between types as needed. If you don't specify a type when declaring a variable, it defaults to Variant.

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. Private procedure

  2. Form procedure

  3. Sub procedure

  4. Property procedure

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

Sub procedures in Visual Basic perform actions but do not return a value to the calling code. Unlike Function procedures, Subs are used when you need to execute code without getting a return value.

Multiple choice
  1. conditional statements

  2. loop structures

  3. methods

  4. procedures

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

Conditional statements like If...Then...Else allow code to execute different paths based on conditions. This controls program flow by making decisions at runtime. While loops also control flow, conditionals are the primary mechanism for branching logic.

Multiple choice
  1. procedure

  2. event

  3. statement

  4. none of these

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

A procedure is a named block of code that performs a specific task. It encapsulates multiple statements that work together as a unit, making code more organized and reusable.

Multiple choice
  1. Sub procedure

  2. General procedure

  3. Function procedure

  4. Event procedure

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

Function procedures return a value to the calling code using the Return statement or by assigning a value to the function name. This distinguishes them from Sub procedures which do not return values.