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 technology programming languages
  1. TRUE.

  2. FALSE

  3. Cant say.

  4. Depends on the valuetype used.

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

Value types in C# cannot normally represent null. However, the introduction of Nullable value types (e.g., int? or Nullable) allows them to hold null values. Because value types can be assigned null under these conditions, the statement is false.

Multiple choice technology programming languages
  1. int[,] testArray;

  2. int[][] testArray;

  3. int[2] testArray;

  4. System.Array[2] testArray;

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

In C#, a two-dimensional array is declared using the syntax 'type[,] arrayName' where the comma indicates the number of dimensions. 'int[,]' declares a 2D array, while 'int[][]' would be a jagged array (array of arrays).

Multiple choice technology programming languages
  1. A strongly typed function pointer.

  2. A light weight thread or process that can call a single method.

  3. A reference to an object in a different process.

  4. An inter-process message channel.

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

A delegate in .NET is a type-safe object-oriented function pointer. Delegates hold references to methods (static or instance) and can be used to pass methods as parameters, implement callback mechanisms, and define events. Unlike raw function pointers, delegates are type-safe and can reference multiple methods (multicast delegates).

Multiple choice technology programming languages
  1. The runtime checks to see that only one version of an assembly is on the machine at any one time.

  2. .NET allows assemblies to specify the name AND the version of any assemblies they need to run.

  3. The compiler offers compile time checking for backward compatibility.

  4. It doesn't

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

.NET prevents DLL Hell by allowing assemblies to specify both the name AND exact version of their dependencies in the manifest. This ensures that an application loads the specific versions of assemblies it was built and tested against, rather than whatever arbitrary version happens to be present. The runtime can then enforce versioning policy and redirect binding if configured.

Multiple choice technology programming languages
  1. For one tab

  2. For all tabs of the Report

  3. Depends how it is defined as global or Private

  4. None of the above

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

Variables defined in a report are accessible across all tabs within that report by default. This global scope allows for consistent calculations and references throughout the document. The option about 'global or Private' is misleading terminology in this context.

Multiple choice technology architecture
  1. For one tab

  2. For all tabs of the Report

  3. Depends how it is defined as global or Private

  4. None of the above

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

Report-level variables have global scope within the report, making them accessible from all tabs. Tab-specific variables would be local to that tab only. Options A and C confuse variable scope with declaration type.

Multiple choice technology programming languages
  1. catch

  2. else

  3. finally

  4. if

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

The if and else keywords are used for conditional branching in Java - if executes code when a condition is true, else handles the false case. catch and finally are part of exception handling (try-catch-finally blocks), not conditional flow control.

Multiple choice technology programming languages
  1. To create a mutable string

  2. To store a single character

  3. To store multiple items of the same type

  4. none

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

An array is a data structure used to store a fixed-size, sequential collection of multiple items of the same data type. A single character is stored in a primitive char variable, and mutable strings are handled by classes like StringBuilder or StringBuffer in Java.

Multiple choice technology databases
  1. Functions always return the same result any time they are called with a specific set of input values.

  2. Functions may return different results each time they are called with a specific set of input values

  3. None

  4. Both of Them

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

Deterministic functions always return the identical result given the same set of input values and database state. Non-deterministic functions (like GETDATE() or RAND()) can return different values on subsequent invocations with the same parameters.

Multiple choice technology web technology
  1. Faster

  2. Slower

  3. The execution speed is similar

  4. All of above

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

To answer this question, the user needs to know the difference between a compiled program and a script.

A compiled program is a set of machine-readable instructions that are generated by a compiler from high-level programming language source code. The compiled program is then executed directly by the computer's CPU.

On the other hand, a script is a set of instructions written in a programming language that is interpreted by an interpreter at runtime. The interpreter reads and executes the code line by line instead of generating machine code.

Now, let's go through each option and explain why it is right or wrong:

A. Faster: This option is generally incorrect. Compiled programs are usually faster than scripts because they are already translated into machine code. The computer can execute machine code directly, which is faster than interpreting source code line by line.

B. Slower: This option is generally correct. Scripts are usually slower than compiled programs because they need to be interpreted at runtime. The interpreter has to read and execute the code line by line, which is slower than executing machine code directly.

C. The execution speed is similar: This option is generally incorrect. In most cases, compiled programs are faster than scripts. However, there may be some cases where the execution speed is similar, such as when the compiled program is poorly optimized or the script is highly optimized.

D. All of the above: This option is incorrect. Option A and C contradict each other, so they cannot both be correct. Option B is generally correct, but there may be some rare cases where a script is faster than a poorly optimized compiled program.

Therefore, the correct answer is:

The Answer is: B. Slower