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 web 2.0
  1. A method

  2. A function

  3. A statement

  4. An operator

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

In JavaScript, void is an operator that evaluates the expression next to it and returns undefined. It is not a method, function, or a flow-control statement.

Multiple choice technology mainframe
  1. True

  2. False

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

The VALUE...THRU clause in COBOL allows you to specify ranges with control over collating sequence direction. You can write VALUE 'A' THRU 'Z' for ascending order or VALUE 'Z' THRU 'A' for descending order. The clause respects the order specified, giving flexibility in range definitions.

Multiple choice technology mainframe
  1. True

  2. False

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

ASCENDING and DESCENDING KEY clauses in COBOL specify sort keys, and these cannot be floating-point data items. Floating-point numbers have imprecise comparison behavior due to representation issues, which makes them unreliable for sorting operations where exact ordering is required. COBOL prohibits using COMP-1 or COMP-2 items as sort keys for this reason.

Multiple choice technology mainframe
  1. Level

  2. Host()

  3. APost

  4. Time

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

Pre-compile parameters in DB2 include Level (for optimization level), Host() (for specifying the host), and APost (for apostrophe handling). 'Time' is not a pre-compile parameter in DB2 - it may be confused with runtime parameters or other database systems, making it the correct answer for 'which is NOT a pre-compile parameter'.

Multiple choice technology mainframe
  1. True

  2. False

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

This is valid Natural language syntax. DEFINE DATA LOCAL defines local variables, END-DEFINE terminates the definition block, MOVE assigns a string literal to the variable, WRITE outputs it to the screen, and END terminates the program. The indentation and structure follow Natural programming conventions correctly.

Multiple choice technology mainframe
  1. TEST

  2. CHECK

  3. JCLCHK

  4. EJCL ALL

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

The CHECK command is widely used in mainframe editors and specific compilers to scan and catch JCL or program code syntax errors without executing the code. While JCLCHK is a CA Broadcom utility, CHECK is the general command interface option designed for standard syntax validation.

Multiple choice technology mainframe
  1. 01

  2. Will not change

  3. 56

  4. Will change

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

In COBOL, NEXT SENTENCE immediately transfers control to the next sentence following the period. Because ADD +1 TO INPUT-COUNT is inside the same sentence (terminated by the period after TEST-1), transferring control to the next sentence bypasses the increment logic, leaving INPUT-COUNT unchanged.

Multiple choice technology programming languages
  1. The program has a syntax error because the required break statement is missing in the switch statement.

  2. The program has a syntax error because the required default case is missing in the switch statement

  3. The switch control variable cannot be double.

  4. No errors

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology web technology
  1. stops the execution of the entire Natural application

  2. stops the execution of the Natural application and also ends the Natural session

  3. terminates the execution of the processing loop and continues

  4. NONE

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

The ESCAPE statement in Natural terminates the current processing loop and continues execution with the statement following the loop. It does not stop the entire application or session.

Multiple choice technology
  1. while command do list ; done

  2. while command ; do list

  3. while command ; do list ; done;

  4. while command ; do list ; done

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

The correct single-line while loop syntax in shell is 'while command ; do list ; done'. The semicolons allow placing the do and done keywords on the same line as commands. Option D has the proper syntax with semicolons in all required positions. Options A and C are missing semicolons, while B is missing 'done'.

Multiple choice technology
  1. array

  2. hash

  3. scalar

  4. vector

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

Scalar variables store a single value and are referred to as name-value pairs because each variable name maps to exactly one value. Arrays store multiple indexed values, hashes store key-value pairs (which are also name-value pairs but for collections), and vectors are ordered collections. Option C is correct as scalars represent the simplest name-value pairing.

Multiple choice technology programming languages
  1. Static variables are global variables

  2. static variales have local to the file/Scope they are declared , but exist throught the program life time

  3. static variables are scoped, Meanaing that they will be destroyed once out of scope

  4. Oh come on , Static variales are only in Java , Do not exist in C

  5. static variales have local to the file they are declared , and they will be destroyed once out of scope

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

Static variables in C have local scope (visible only within the function/block they're declared in) but static storage duration (they persist for the entire program execution). They retain their values between function calls and are initialized only once. This makes them different from both global variables (which have global scope) and automatic local variables (which are destroyed when out of scope).