Programming with IBM Enterprise PL/I v5.0 (C9050-041)

Page:    1 / 10   
Total 146 questions

Which of the following is NOT a valid way to set a pointer P to zero?

  • A. UNSPEC(P) = ''B;
  • B. P = PTRVALUE(0);
  • C. P = SYSNULL();
  • D. P = 0;


Answer : D

Given the following piece of code, what will be the output of the preprocessor?
%F: PROC(S) RETURNS(CHAR);
DCL S CHAR;
RETURN (SUBSTR(S, 1, 1));
%END;
PUT (F(ABC));
%ACTIVATE F;
PUT (F(ABC));

  • A. PUT (F(ABC));PUT (A);
  • B. PUT (A);PUT (F(ABC));
  • C. PUT (A);PUT (A);
  • D. PUT (F(ABC));PUT (F(ABC));


Answer : A

If the physical dataset referred to by DDIN has a record length of 200 and a RECFM of F, what happens after executing the following code?
DCL DDIN FILE RECORD INPUT;
DCL P PTR;
DCL 1 INSTR BASED(P),
2 A CHAR(100),
2 B CHAR(100);
ALLOCATE INSTR;
OPEN FILE(DDIN);
READ FILE(DDIN) INTO(INSTR);

  • A. One record will be read into the buffer and the pointer will be set accordingly.
  • B. One record will be read into the structure INSTR.
  • C. READ INTO cannot be used on a BASED structure.
  • D. Program will abend because P has not been properly initialized.


Answer : B

Given the following code, what declaration of I will cause an infinite loop under default condition enablement?
DO I = 1 TO 99;

  • A. DCL I FIXED BIN (7);
  • B. DCL I FIXED DEC (3,0);
  • C. DCL I PIC'99';
  • D. DCL I FLOAT;


Answer : C

In which of the following cases is it possible to change the value of a variable in a routine when it is passed to the routine as an argument?

  • A. The argument is declared as FIXED BIN(15), and the corresponding parameter is declared as FIXED BIN(15) BYVALUE.
  • B. The argument is declared as FIXED BIN(15), and the corresponding parameter is declared as FIXED DEC(7) BYADDR.
  • C. The argument is declared as FIXED DEC(7), and the corresponding parameter is declared as FIXED DEC(7) BYADDR.
  • D. The argument is declared as CHAR(10) VAR, and the corresponding parameter is declared as CHAR(10).


Answer : C

What is the result, if any, of executing the following code?
DCL A BIT(1) INIT('0'B);
DCL B BIT(1) INIT('0'B);
DCL C BIT(1) INIT('1'B);
A = B ! C;

  • A. The value of A is '0'B
  • B. The value of A is '1'B.
  • C. The value of A is unpredictable.
  • D. There is no result, because the syntax is wrong.


Answer : B

What is the most appropriate way to assign a value to variable A?
DCL A BIN FIXED(15);

  • A. A = '17';
  • B. A = 17.29;
  • C. A = '1729'X;
  • D. A = 17;


Answer : D

Given the following code, what procedure will be accepted by the compiler?
DCL A DIM (10) CHAR (100) VAR BASED (P);
DCL P PTR;
ALLOCATE A;
CALL SUB (P);

  • A. SUB: PROCEDURE (P);DCL P PTR;DCL A DIM (10) CHAR (100) VAR BASED (P);END SUB;
  • B. SUB: PROCEDURE (P);DCL P PTR;DCL A DIM (*) CHAR (100) VAR BASED (P);END SUB;
  • C. SUB: PROCEDURE (P);DCL P PTR;DCL A DIM (10) CHAR (*) VAR BASED (P);END SUB;
  • D. SUB: PROCEDURE (P);DCL P PTR;DCL A DIM (*) CHAR (*) VAR BASED (P);END SUB;


Answer : A

What is the value of A after executing the following code?
DCL A CHAR(6) INIT ('ABCDEF');
DCL B CHAR(10) INIT ('0123456789');
A = SUBSTR(B,5,3);

  • A. '456 '
  • B. ' 456'
  • C. '456DEF'
  • D. 'ABC456'


Answer : A

Given the following code, with what attribute should the variable EOF be declared?
DO WHILE(^EOF);

  • A. FIXED BIN (7)
  • B. BIT (1)
  • C. CHAR (1)
  • D. FIXED DEC (3)


Answer : B

What will be output by the following program?
TEST: PROC OPTIONS(MAIN);
DCL A CONTROLLED FIXED BIN(31);
ALLOC A;
ALLOC A;
CALL SUB(A);
PUT SKIP LIST( ALLOCN(A) );
SUB: PROC( B );
DCL B CONTROLLED FIXED BIN(31);
FREE B;
ALLOC B;
ALLOC B;
FREE B;
ALLOC B;
END;
END;

  • A. 2
  • B. 3
  • C. 4
  • D. 5


Answer : B

Which of the following is a restriction using the BYVALUE attribute?

  • A. It can be specified only for scalar arguments and parameters that can be passed in registers.
  • B. It can be specified only for scalar arguments and parameters with a size of four bytes.
  • C. It can be specified only for aggregate arguments and parameters.
  • D. It can be specified only for scalar arguments and parameters whose lengths and sizes are known at compile time.


Answer : D

What is the value of B after executing the following code?
DCL A CHAR(10) INIT('12A4BABCAB');
DCL B BIN FIXED(31) INIT(0);
B = INDEX(A,'AB');

A. 2 -

B. 3 -

C. 6 -

D. 9 -



Answer : C Topic 2, B B

Given the following code, what will happen if the variable MAX has a value larger than
32767?
DCL I FIXED BIN (15);
DCL MAX FIXED BIN (31);
DO I = 1 TO MAX;

  • A. The loop will stop executing when I reaches a value of 32767.
  • B. The loop will stop executing when I reaches the value in MAX.
  • C. The loop will stop executing when I reaches a value equivalent to MAX + 1.
  • D. The loop will stop executing with an ABEND or run infinitely.


Answer : D

If the physical dataset referred to by DDOUT has a maximum record length of 4096 and a
RECFM=V, what happens after executing the following code?
DCL DDOUT FILE RECORD OUTPUT;
DCL OUT_CHAR CHAR(500) VARYING INIT('This is a varchar test');
OPEN FILE(DDOUT);
WRITE FILE(DDOUT) FROM(OUT_CHAR);

  • A. One record with a length of 22 will be written to the output file.
  • B. One record with a length of 500 will be written to the output file.
  • C. One record with a length of 4096 will be written to the output file.
  • D. An error will occur because of mismatch of record length.


Answer : A

Page:    1 / 10   
Total 146 questions