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 programming languages
  1. open cursor; ---some statements close;

  2. open cursor; fetch into variables; ---some statements close cursor;

  3. open cursor; fetch into variables; ---some statements close;

  4. All of the above

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

A standard explicit cursor lifecycle in PL/SQL involves opening the cursor, fetching the rows into variables within a loop, and closing the cursor. The correct option accurately reflects this sequence.

Multiple choice technology mainframe
  1. Subroutine should start with this instruction

  2. To convert all the local variables in the subroutine as global variables

  3. To convert all the variables used in subroutine as local variables

  4. Function should start with this instrucion

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

PROCEDURE marks the start of a subroutine and ensures all variables within it are local to that routine unless exposed on the PROCEDURE statement. Without it, variables would be global across the entire exec.

Multiple choice technology programming languages
  1. a program must always begin with a PROCEDURE statement and end with an END statement

  2. PL/I instructions can be coded between positions 1 and 72

  3. you have to declare each variable that you are going to use

  4. a program can be composed out of different procedures

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

Every executable PL I program requires a PROCEDURE statement with OPTIONS MAIN to start and an END to terminate. Code is written in columns 2 72, variables need not always be declared due to default typing, and while procedures can contain internal procedures, the main program structure is what option A describes.

Multiple choice technology programming languages
  1. REPEAT 5 TIMES; instruction; END;

  2. DO J=1 TO 5; instruction; END;

  3. COUNTER = 1; DO WHILE COUNTER < 5; COUNTER = COUNTER + 1; instruction; END;

  4. REPEAT VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER = 5; instruction; END;

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

To repeat an instruction 5 times in PL/I, the programmer can use a loop construct.

Option A is not a valid PL/I syntax.

Option B is a correct way to repeat an instruction 5 times in PL/I. It uses a DO loop with a loop control variable J that iterates from 1 to 5, executing the instruction each time.

Option C is also a valid way to repeat an instruction 5 times in PL/I, but it uses a WHILE loop instead of a DO loop. It initializes a counter variable to 1 and repeats the instruction while the counter is less than 5.

Option D is also a valid way to repeat an instruction 5 times in PL/I, but it uses a REPEAT loop with a loop control variable COUNTER that iterates from 1 to 5, executing the instruction each time.

Therefore, the correct answer is:

The Answer is: B

Multiple choice technology programming languages
  1. A B Z E F Z X

  2. A B X Z E F G H Z X

  3. A B X Z E F Z G H Z

  4. A B X Z G H Z

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

MYPROG calls INIT which executes A, B, then READ X which executes X, then instruction Z, then TERM which executes G, H, then instruction Z again. LOOP is defined but never called, so E and F never execute.