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 technology mainframe
  1. Extracts the SQL statements and place them into load.

  2. Extracts the SQL statements and place them into DBRM.

  3. Extracts the COBOL statements and place them into DBRM.

  4. Extracts the COBOL statements and place them into load.

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

The DB2 precompiler processes source code containing embedded SQL, extracts the SQL statements to create a Database Request Module (DBRM), and replaces them with host-language calls.

Multiple choice technology programming languages
  1. takes Boolean condition as parameter and shows error dialog if condition is true; but proceeds without interruption if condition is false.

  2. takes Boolean condition as parameter and throws exception if condition is false; but proceeds without interruption if condition is true.

  3. takes Boolean condition as parameter and shows error dialog if condition is false; but proceeds without interruption if condition is true.

  4. None of above

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

Debug.Assert checks a condition and shows an error dialog only when the condition is false (indicating a failure). When the condition is true (normal case), execution continues uninterrupted. The dialog helps catch logic errors during development.

Multiple choice technology programming languages
  1. Structs are value-type variables

  2. Structs are saved on stack

  3. structs can be inherited.

  4. None of the above.

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

Structs in C# are value types stored on the stack and do not support inheritance (except implicitly inheriting from System.ValueType). Since all options are true, 'None of the above' is correct.

Multiple choice technology programming languages
  1. Late binding defers type identification process until run time, so prefer Late Binding whenever possible

  2. Always enable Option Explicit and Option Strict options(while using Visual Basic.NET)

  3. If Com objects is referred in code, destroy COM objects always after use

  4. While implementing threading, do not use Thread.Abort to terminate other threads

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

Late binding defers type resolution to runtime, which introduces significant performance overhead. For optimal performance, early binding should always be preferred, making the statement favoring late binding false.

Multiple choice technology programming languages
  1. No. You can write a program to catch just the exceptions you want.

  2. No. But if a program catches one type of exception it must catch all other types as well.

  3. Yes. If a program is not written to catch all exceptions it will not compile.

  4. Yes. A program can not do I/O unless it catches all exceptions.

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

Programs are not required to catch all exceptions. Developers can choose to catch only specific exceptions they want to handle, while others can be allowed to propagate up the call stack or terminate the application.

Multiple choice technology programming languages
  1. Some of the statements in a try{} block will never throw an exception.

  2. The statements in a try{} block may throw several types of exception.

  3. The try{} block can not contain loops or branches.

  4. The try{} block must appear before the catch{} blocks.

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

The try{} block is used to enclose code that might throw exceptions. It can contain loops, branches (if/else), and any other valid statements - there is no such restriction. Option A is false because some statements in try blocks will indeed throw exceptions when runtime conditions trigger them. Option B is false because try blocks CAN throw multiple exception types handled by different catch blocks. Option C is the FALSE statement - try blocks CAN contain loops and branches. Option D is true - try must precede catch.

Multiple choice technology programming languages
  1. There can be several catch{} blocks in a try/catch structure.

  2. The catch{} block for a child exception class must PRECEED that of a parent execption class.

  3. The catch{} block for a child exception class must FOLLOW that of a parent execption class.

  4. If there is no catch{} block there must be a finally{} block.

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

To answer this question, the user needs to have knowledge of the try-catch-finally error handling mechanism in programming.

Option A: This statement is true. We can have several catch{} blocks in a try/catch structure in order to handle different types of exceptions.

Option B: This statement is true. The catch{} block for a child exception class must precede that of a parent exception class because if a child exception is caught by a parent catch{} block, the catch{} block for the child exception will never be executed.

Option C: This statement is false. The catch{} block for a child exception class must follow that of a parent exception class. This is because if the catch{} block for a child exception class precedes that of a parent exception class, the parent catch{} block will catch the exception first and the child catch{} block will never be executed.

Option D: This statement is false. If there is no catch{} block, there does not necessarily have to be a finally{} block. A finally{} block is optional and is used to execute code regardless of whether an exception was thrown or not.

Therefore, the answer is:

The Answer is: C

Multiple choice technology programming languages
  1. There must always be one, following the last catch{} block.

  2. There can be zero or one immediately after each catch{} block.

  3. There can be zero or one, following the last catch{} block.

  4. There can be any number, following the last catch{} block.

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

In try/catch/finally structure, there can be at most ONE finally block, and if present, it must appear AFTER the last catch block. The finally block is optional (can be zero), but if used, only one is allowed per try-catch structure. Option C correctly states: there can be zero or one, following the last catch block.

Multiple choice technology programming languages
  1. getenv(), setenv()

  2. getenv(), putenv()

  3. readenv(), writeenv()

  4. You cannot environmement variables inside a program

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

Standard C library functions for environment variables are getenv() to retrieve and putenv() to set/modify environment variables. Option A incorrectly pairs setenv() (which exists but putenv() is the more common POSIX standard). Option C uses non-existent function names. Option B correctly pairs getenv() and putenv().

Multiple choice technology operating systems
  1. True

  2. False

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

To disable Dr. Watson in Windows, you set the 'Auto' value to '0' (disabled), not '1'. The registry key path is correct, but the value should be '0' to turn it off. Setting it to '1' would actually enable automatic debugging.

Multiple choice technology programming languages
  1. INTOEMPTY

  2. OBJECTS

  3. Only b

  4. Both a and b

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

To solve this question, the user needs to have knowledge of the IMPORT command in SQL.

The correct answer is:

D. Both a and b

Explanation:

The IMPORT command is used to import data from an external file into a SQL database. The IMPORT command has several parameters, one of which is the "PARAMETERS" parameter. The "PARAMETERS" parameter has several subcommands, including "INTOEMPTY" and "OBJECTS".

  • The "INTOEMPTY" subcommand is used to import data into an empty table.
  • The "OBJECTS" subcommand is used to import data into an existing table.

Therefore, option D is correct because both subcommands "INTOEMPTY" and "OBJECTS" are subcommands of the IMPORT parameter.

Multiple choice technology databases
  1. It produces the output Procedure B calling C

  2. It produces the output Procedure C calling B

  3. It produces a compilation error because procedure C requires a forward declaration

  4. It produces a compilation error because procedure B requires a forward declaration.

  5. It produces a compilation error because identified g_value is not declared in procedure A

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

The package has a circular reference problem: procedure C calls procedure B, but procedure C appears before procedure B in the package body. Without a forward declaration, procedure C cannot find procedure B when compiling, resulting in an error. Option C correctly identifies this forward declaration issue for procedure C. Option D is incorrect because procedure B does NOT need a forward declaration - it appears later in the code and is visible to C. Options A and B are incorrect because the code cannot produce any output - it fails to compile.