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
-
A method
-
A function
-
A statement
-
An operator
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.
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.
A
Correct answer
Explanation
In COBOL, the JUSTIFIED clause is used to align data in alphabetic or alphanumeric fields. It cannot be applied to variables defined with USAGE IS POINTER, which represent memory addresses and require strict, unformatted storage, making the statement true.
A
Correct answer
Explanation
The EJECT statement in COBOL is used to force a page break in the compiler listing output. When the compiler encounters EJECT, it advances to a new page before continuing compilation. This helps organize the listing into logical sections for better readability and debugging.
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.
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'.
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.
-
TEST
-
CHECK
-
JCLCHK
-
EJCL ALL
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.
-
01
-
Will not change
-
56
-
Will change
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.
-
The program has a syntax error because the required break statement is missing in the switch statement.
-
The program has a syntax error because the required default case is missing in the switch statement
-
The switch control variable cannot be double.
-
No errors
-
#FIELDA (N3) = <100>
-
#FIELDA (N3) INIT <100>
-
#FIELDA (N3) INITIALISE <100>
-
ALL
B
Correct answer
Explanation
In Natural Cobol, variables are initialized using the INIT keyword followed by the initial value in angle brackets. The correct syntax is #FIELDA (N3) INIT <100>.
-
stops the execution of the entire Natural application
-
stops the execution of the Natural application and also ends the Natural session
-
terminates the execution of the processing loop and continues
-
NONE
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.
-
while command do list ; done
-
while command ; do list
-
while command ; do list ; done;
-
while command ; do list ; done
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'.
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.
-
Static variables are global variables
-
static variales have local to the file/Scope they are declared , but exist throught the program life time
-
static variables are scoped, Meanaing that they will be destroyed once out of scope
-
Oh come on , Static variales are only in Java , Do not exist in C
-
static variales have local to the file they are declared , and they will be destroyed once out of scope
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).