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

  2. MOVE

  3. FIND

  4. STRING

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

In standard COBOL, the verbs ACCEPT, MOVE, and STRING are all valid COBOL verbs. FIND is not a standard COBOL verb - it's typically used in database systems like SQL or in some mainframe query utilities, but not in core COBOL programming. This makes 'FIND' the correct answer to what 'is not a COBOL verb'.

Multiple choice technology
  1. toEval()

  2. toStr()

  3. string()

  4. eval()

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

eval() is a JavaScript/ActionScript function that evaluates a string expression and can access variables, properties, objects, or movie clips by name. It dynamically executes code stored as strings. The other options (toEval, toStr, string) are not valid functions for this purpose.

Multiple choice technology mainframe
  1. COMP-1

  2. COMP

  3. COMP-3

  4. DISPLAY

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

COMP-1 (single-precision floating point) in COBOL does not accept a PIC (PICTURE) clause because it uses internal binary representation, not the character-based format that PIC defines. COMP, COMP-3, and DISPLAY can all have PIC clauses to define their data layout. COMP-1 is pre-defined as a 4-byte floating-point format.

Multiple choice technology programming languages
  1. Compilation succeeds

  2. Compilation fails due only to an error on line 15

  3. Compilation fails due only to an error on line 16

  4. Compilation fails due only to an error on line 17

  5. Compilation fails due only to an error on line 18

  6. Compilation fails due to errors on multiple lines

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

The BufferedWriter constructor requires a Writer object as its argument. On line 15, a File object is passed, which does not inherit from Writer, causing a compilation failure. Lines 16, 17, and 18 are valid because FileWriter, PrintWriter, and BufferedWriter all extend Writer.

Multiple choice technology databases
  1. NULL

  2. 0

  3. Results in a compilation error

  4. An exception will be raised

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

The answer to the question is A. NULL.

When a variable is declared in PL/SQL without an initial value, it is initialized to NULL. This means that the variable has no value, and any attempt to use it will result in a NULL value.

Option B is incorrect because the value of a NUMBER variable is not automatically initialized to 0. Option C is incorrect because a compilation error will not occur if a variable is declared without an initial value. Option D is incorrect because an exception will not be raised if a variable is declared without an initial value.

Here is an example of how a NULL value is handled in PL/SQL:

DECLARE
  v_number NUMBER;
BEGIN
  v_number := NULL;
  dbms_output.put_line(v_number); -- This will print 'NULL'
END;

As you can see, the value of v_number is printed as NULL when it is first used in the executable section of the PL/SQL block. This is because the variable was declared without an initial value, and therefore its value is NULL.

Multiple choice technology databases
  1. Header

  2. Declarative

  3. Executable

  4. Exception

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

Error trapping uses EXCEPTION handlers within the EXCEPTION section of a PL/SQL block. The EXECUTABLE section contains the runtime code that may raise exceptions. The EXCEPTION section is where handlers are defined. Header has no error handling. Declarative defines variables/types.

Multiple choice technology testing
  1. functionOpenWindow ( )

  2. funOpenWindow123 ( )

  3. OpenWindow ( )

  4. funcOpenWindow ( )

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

In QTP (QuickTest Professional) scripting, function names must follow specific naming conventions. The function name must start with 'func' followed by the actual name. 'funcOpenWindow()' follows this convention correctly. The other options are invalid: 'functionOpenWindow()' uses the full word 'function', 'funOpenWindow123()' is an incorrect abbreviation, and 'OpenWindow()' lacks the required prefix. These naming rules help distinguish user-defined functions from built-in functions and keywords.

Multiple choice technology
  1. MakeNull

  2. SetNull

  3. NullToEmpty

  4. IfNull

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

IfNull is primarily a SQL function (like MySQL's IFNULL), not a DataStage transformer function. DataStage uses SetNull(), MakeNull(), NullToEmpty(), IsNull(), and NullToValue() for null handling. The question tests familiarity with DataStage-specific function names versus generic SQL functions.

Multiple choice technology mainframe
  1. Scope terminator is used to mark the end of a verb

  2. Scope terminator is used to mark the end of a statement

  3. Both 1 and 2

  4. None of the above

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

A scope terminator marks the end of a verb or statement in COBOL. Explicit scope terminators like END-IF, END-PERFORM, END-READ make the code more readable and prevent ambiguity by clearly defining where a conditional or iterative construct ends. Both options 1 and 2 correctly describe the purpose of scope terminators.

Multiple choice technology mainframe
  1. IF THEN/ELSE

  2. COND

  3. BOTH

  4. Steps cannot be skipped in JCL.

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

JCL steps can be skipped using both conditional processing methods. The COND parameter tests return codes from previous steps. IF/THEN/ELSE (or IF/THEN/ELSE/ENDIF) constructs provide conditional logic. Statement D is false - steps can indeed be conditionally executed or skipped.

Multiple choice technology mainframe
  1. IF THEN/ELSE

  2. COND

  3. BOTH

  4. Steps cannot be skipped in JCL.

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

JCL steps can be skipped using both conditional processing methods. The COND parameter tests return codes from previous steps. IF/THEN/ELSE (or IF/THEN/ELSE/ENDIF) constructs provide conditional logic. Statement D is false - steps can indeed be conditionally executed or skipped.

Multiple choice technology mainframe
  1. IF THEN/ELSE

  2. COND

  3. BOTH

  4. Steps cannot be skipped in JCL.

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

JCL steps can be skipped using both COND parameters on EXEC statements and IF/THEN/ELSE construct statements. COND conditionally skips based on return codes from previous steps. IF/THEN/ELSE provides more complex conditional logic. Both are valid methods for conditional execution.

Multiple choice technology databases
  1. The exception B will be handled in inner block

  2. The exception B will be handled in outer block exception handler

  3. The exception will not be handled as there is no handler defined for B in inner block

  4. The exception section in inner block is executed and also Outer block exception section as we have defined there too

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

When exception B is raised in the inner block's ELSE clause, it has no matching handler in that inner block (which only handles A). Unhandled exceptions propagate to the enclosing block, where B is caught. Option B correctly describes this propagation behavior.