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 databases
  1. 0

  2. NULL

  3. Depends on the scale and precision of the datatype.

  4. Without initialization, a variable cannot be used in the executable section of the block.

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

In PL/SQL, variables that are declared but not initialized default to NULL when execution begins. They do not default to 0, their default value does not depend on scale/precision, and they can still be used in the executable section.

Multiple choice technology databases
  1. If-Then-Else

  2. While loop

  3. GOTO

  4. DECODE

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

GOTO provides unconditional transfer of control to a labeled section within a PL/SQL block, allowing immediate jump to a specific part without any condition. If-Then-Else requires condition evaluation, While loops execute based on a condition, and DECODE is a function for value substitution, not a control structure.

Multiple choice technology databases
  1. Declaration

  2. Execution

  3. Exception

  4. Header

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

The Exception section (also called exception handler) is where user-defined and predefined exceptions are trapped and handled using WHEN clauses. The Declaration section declares variables and exceptions, the Execution section contains the main logic, and there is no 'Header' section in PL/SQL block structure.

Multiple choice technology programming languages
  1. Runtime Exception

  2. finally block will be executed

  3. finally block will not be executed

  4. Compilation error in else block

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

System.exit() terminates the JVM immediately, preventing the finally block from executing. Additionally, the while(true) loop in the if branch never exits, so the finally block would never be reached in that case either. Only if neither branch executes would finally run, but the structure guarantees one of them does.

Multiple choice technology programming languages
  1. Runtime Exception

  2. finally block will be executed

  3. finally block will not be executed

  4. Compilation error in else block

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

This is a duplicate of question 149704. System.exit() terminates the JVM immediately, preventing the finally block from executing. The while(true) loop also never exits. In both cases, the finally block is unreachable.

Multiple choice technology storage
  1. A) Parameter type mismatches.

  2. B ) Errors in requirements.

  3. C ) Undeclared variables.

  4. D ) Uncalled functions.

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

Static analysis examines code without executing it and can detect syntax errors, undeclared variables, type mismatches, and unreachable code. However, it cannot validate whether requirements are correctly captured or if the software meets user needs; requirements errors require manual review or dynamic testing. Options A, C, and D are all detectable through static code analysis.

Multiple choice technology storage
  1. a) The use of a variable before it has been defined

  2. b) Unreachable (“dead”) code

  3. c) Whether the value stored in a variable is correct

  4. d) The re-definition of a variable before it has been used

  5. e) Array bound violations

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

Static analysis can detect structural issues like undefined variables (a), unreachable code (b), variable redefinitions (d), and array bounds violations (e) by analyzing code without execution. However, it cannot determine if a stored value is logically correct for the intended computation (c); that requires understanding requirements and dynamic testing.

Multiple choice technology testing
  1. 1 test for statement coverage, 3 for branch coverage

  2. 2 tests for statement coverage, 2 for branch coverage

  3. 2 tests for statement coverage. 3 for branch coverage

  4. 3 tests for statement coverage, 2 for branch coverage

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

Two test cases are sufficient for both statement and branch coverage. The first test (e.g., A=10, B=5, D=5) covers the true branch of the first IF and the true branch of the second IF. The second test (e.g., A=5, B=10, D=10) covers the false branches, achieving full coverage.

Multiple choice technology testing
  1. The use of a variable before it has been defined

  2. Unreachable (“dead”) code

  3. Whether the value stored in a variable is correct

  4. The re-definition of a variable before it has been used

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

Static analysis examines code without executing it, so it can find structural issues like undefined variables, unreachable code, or variable redefinitions. However, it cannot verify semantic correctness - whether the value stored in a variable matches the intended business logic. Static analysis tools don't understand your requirements, so they can't tell if 'x = 5' should have been 'x = 10' - only dynamic testing with known inputs and expected outputs can verify correctness.

Multiple choice technology testing
  1. Equivalence partitioning

  2. State transition testing

  3. LCSAJ

  4. Syntax testing

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

Black box techniques test software without examining internal code structure. Equivalence partitioning, state transition testing, and syntax testing are all black box techniques - they focus on inputs, outputs, and external behavior. LCSAJ (Linear Code Sequence and Jump) is a white box structural testing technique that requires analyzing code paths, branches, and control flow within the program's source code.

Multiple choice technology testing
  1. Random testing

  2. Data Flow testing.

  3. Statement testing.

  4. Syntax testing.

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

BS7925-II standard for software component testing defines white-box techniques as those examining internal structure like control flow, data flow, and statement coverage. Syntax testing is a black-box technique that validates input format against a grammar without considering internal code implementation. Random testing is also not a white-box technique, but syntax testing is more definitively a structural black-box method.

Multiple choice technology programming languages
  1. 0

  2. 1

  3. 2

  4. undefined

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

When a user-declared constructor is defined, the compiler stops generating the default constructor. This struct has two user-declared constructors: a copy constructor 'A(A& a)' and a converting constructor 'A(double d)'. Because at least one constructor is explicitly declared, the compiler will NOT generate any additional constructors (no default constructor, no copy constructor since one exists, no move constructors). Therefore, the number of implicitly-defined constructors is 0.