Programming with IBM Enterprise PL/I v5.0

Page:    1 / 10   
Exam contains 146 questions

A programmer has been asked to write a program that tests a variable, X, and writes out A,
B, C or D if X is 0, 1, 2 or 3 respectively and writes out E when X has none of those values.
Which of the following programs represents the best practice using IF or SELECT statements?

  • A. SUB1: PROC( X );DCL X FIXED UNSIGNED;IF X = 0 THENPUT SKIP LIST ( 'A');ELSEIF X = 1 THENPUT SKIP LIST ( 'B');ELSEIF X = 2 THENPUT SKIP LIST ( 'C');ELSEIF X = 3 THENPUT SKIP LIST ( 'D');ELSEPUT SKIP LIST ( 'E');END;
  • B. SUB2: PROC ( X );DCL X FIXED UNSIGNED;IF X < 2 THENIF X = 0 THENPUT SKIP LIST ( 'A');ELSEPUT SKIP LIST ( 'B');ELSEIF X = 2 THENPUT SKIP LIST ( 'C');ELSEIF X = 3 THENPUT SKIP LIST ( 'D');ELSEPUT SKIP LIST ( 'E');END;
  • C. SUB3: PROC( X ); DCL X FIXED UNSIGNED;SELECT;WHEN ( X = 0 )PUT SKIP LIST ( 'A');WHEN( X = 1 )PUT SKIP LIST ( 'B');WHEN( X = 2 )PUT SKIP LIST ( 'C');WHEN( X = 3 )PUT SKIP LIST ( 'D');OTHERWISEPUT SKIP LIST ( 'E');END;END;
  • D. SUB4: PROC( X ); DCL X FIXED UNSIGNED;SELECT ( X );WHEN ( 0 )PUT SKIP LIST ( 'A');WHEN ( 1 )PUT SKIP LIST ( 'B');WHEN ( 2 )PUT SKIP LIST ( 'C');WHEN ( 3 )PUT SKIP LIST ( 'D');OTHERWISEPUT SKIP LIST ( 'E');END;END;


Answer : D

To validate the assignment in the following code, which condition should be enabled?
TEST: PROC(A, B);
DCL (A, B) CHAR (*);
A = B;
END;

  • A. SIZE
  • B. STRINGRANGE
  • C. STRINGSIZE
  • D. SUBSCRIPTRANGE


Answer : C

Which of the following would NOT access the third element of A?
DCL 1 XY(5),
2 A(4) CHAR(4);

  • A. XY(1,3).A
  • B. XY.A(1,3)
  • C. XY(1).A(3)
  • D. XY(3).A(1)


Answer : D

The following code calls an external function procedure. Which program matches the entry declaration?
DCL F FLOAT;
DCL X CHAR(1);
DCL FUN ENTRY (FIXED BIN (15), FLOAT) RETURNS (CHAR(1));
X = FUN(1, F);

  • A. FUN: PROCEDURE (K, F) RETURNS (CHAR(1));DCL K FIXED BIN (15);DCL F FLOAT;END;
  • B. FUN: PROCEDURE (K, F) RETURNS (CHAR(1));DCL K FIXED BIN (31);DCL F FLOAT;END;
  • C. FUN: PROCEDURE (K, F) RETURNS (CHAR(1));DCL K FIXED DEC (15);DCL F FLOAT;END;
  • D. FUN: PROCEDURE (K, F) RETURNS (FIXED BIN (15));DCL K FIXED BIN (15);DCL F FLOAT;END;


Answer : A

If the physical dataset referred to by DDOUT has a record length of 200 and RECFM=F, what happens after executing the following code?
DCL DDOUT FILE RECORD OUTPUT;
DCL OUT_CHAR CHAR(200) INIT('Hello World');
WRITE FILE(DDOUT) FROM(OUT_CHAR);

  • A. One record with a length of 11 will be written to the output file.
  • B. One record with a length of 200 will be written to the output file.
  • C. Compiler error because there is no OPEN statement.
  • D. Runtime error because there is no OPEN statement.


Answer : B

Given the following code, what construct is equivalent?
SELECT;
WHEN (A < 1) B += 1;
WHEN (A < 2) B += 2;
WHEN (A < 3) B += 3;
OTHERWISE B = 0;
END;

  • A. IF A < 1 THENB += 1;ELSEIF A < 2 THENB += 2;ELSEIF A < 3 THENB += 3;ELSEB = 0;
  • B. IF A < 1 THEN B += 1;IF A < 2 THEN B += 2;IF A < 3 THEN B += 3;ELSE B = 0;
  • C. SELECT;WHEN (A < 3) B += 3;WHEN (A < 2) B += 2;WHEN (A < 1) B += 1;OTHERWISE B = 0;END;
  • D. SELECT;WHEN (A < 1) B += 1;WHEN (A < 2) B += 2;WHEN (A < 3) B += 3;END;


Answer : A

Given the following program, the compiler will produce the warning message "The structure member A2 is declared without any data attributes. A level number may be incorrect.".
What is the best way to correct the program?
TEST: PROC OPTIONS(MAIN);

DCL -
1 A,
3 A1 FIXED BIN(31),
3 A2,
3 A3 FIXED BIN(31),
3 A4 FIXED BIN(31);
END;

  • A. Add the attribute CHAR(8) to the declare for A2
  • B. Change the level number on the declare for A2 to 2
  • C. Change the level number on the declare for A3 to 4
  • D. Change the level numbers on the declares for A3 and A4 to 4


Answer : D

What changes should be made, if any, to the following code?
DCL A CHAR(100) BASED(P);
DCL P PTR;
READ FILE(DDIN) INTO(A);

  • A. READ FILE(DDIN) SET(A);
  • B. READ FILE(DDIN) INTO(P);
  • C. READ FILE(DDIN) SET(P);
  • D. No changes necessary because the code is correct.


Answer : C

Which of the following pieces of code will result in a compiler error message?

  • A. ON ENDFILE (SYSIN)DO;PUT LIST('End of file reached.');EOF = '1'B;END;
  • B. ON ENDFILE (SYSIN)BEGIN;PUT LIST('End of file reached.');EOF = '1'B;END;
  • C. IF EOF THENDO;K = 0;L = 1;END;
  • D. IF EOF THENBEGIN;K = 0;L = 1;END;


Answer : A

What is the most appropriate declaration for the variable A?
A = 'ABCDEF';

  • A. DCL A BIN FIXED(15);
  • B. DCL A CHAR(6);
  • C. DCL A DEC FIXED (15,3);
  • D. DCL A PIC '999999';


Answer : B

What will be printed when the following subroutine is called for the third time?
A : PROC;
DCL X PIC '9' INIT(0);
X = X + 1;
PUT SKIP LIST ('THE VALUE OF X IS :'!!X);
X = X + 1;
END A;

  • A. THE VALUE OF X IS :1
  • B. THE VALUE OF X IS :2
  • C. THE VALUE OF X IS :3
  • D. THE VALUE OF X IS :5


Answer : A

Given the following piece of code, what will be output?

  • A. PROCEDURE OPTIONS (MAIN); DCL K CHAR (1) INIT ('A'); CALL B;
  • B. PROCEDURE; DCL K CHAR (1) INIT ('B'); CALL C;
  • C. PROCEDURE ; DCL K CHAR (1) INIT ('C'); PUT (K); CALL D; END C;
  • D. PROCEDURE; PUT (K); END D; END B; PUT (K); END A;
  • E. C A A
  • F. C C A
  • G. C B A
  • H. C A B


Answer : C

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

  • A. One record with a length of 220 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 196 will be written to the output file.
  • D. An error will occur because of mismatch of record length.


Answer : D

Which is the most appropriate code to turn all of the bits in A ON?
DCL A BIT(8);

  • A. A = 255;
  • B. A = '11111111'B;
  • C. A = 11111111B;
  • D. A = -1;


Answer : B

In which of the following situations can a subroutine be replaced by a function without any major changes to the code?

  • A. When the subroutine changes an array parameter
  • B. When the subroutine changes a structure parameter
  • C. When the subroutine changes more than one parameter
  • D. When the subroutine changes only one scalar parameter


Answer : D

Page:    1 / 10   
Exam contains 146 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary.com is owned by MBS Tech Limited: Room 1905 Nam Wo Hong Building, 148 Wing Lok Street, Sheung Wan, Hong Kong. Company registration number: 2310926
Certlibrary doesn't offer Real Microsoft Exam Questions. Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.
Terms & Conditions | Privacy Policy