You are on page 1of 11

COBOL/COBOL II Questionnaire

COBOL/COBOL II QUESTIONNAIRE
Q.1 A Q.2 A COBOL is an acronym. What does it stand for? Common Business-Oriented Language. What are the structured development aids introduced in COBOL II? COBOL II offers the following options : a. EVALUATE : permits CASE construction. b. The in-line PERFORM : permits 'do construction. c. TEST BEFORE and TEST AFTER in the PERFORM statements : permit 'do while' and 'do until' constructions. What feature in COBOL II is Similar to features in other programming languages? The most obvious are the explicit scope terminators for most processing actions. An alphabetical list indicates the variety : end-add end-if end-search end-call end-multiply end-start end-compute end-perform end-string end-delete end-read end-subtract end-divide end-return end-unstring end-evaluate end-rewrite end-write The scope terminator ',' (as well as the period '.') is still available. Q.4 A What are the three categories of data defined in the DATA division? The three categories of data defined in DATA division are : The file section (FD) information Working storage information Linkage-section data definitions When is using READ INTO not advisable? READ INTO performs two actions : the file is read into the buffer and the record is moved to working storage. The construct assumes that the LRECL of every record is the same. When used with variable-length records, the results may be "unexpected". What are the techniques for achieving "top-down" programming? Top-down is an effort to avoid spaghetti code and is sometimes referred to as "go to less" programming. Processing is performed from beginning to the end of paragraphs. Performs rather than "go tos" are used to move through code. The PERFORM... THRU structure should be used only when THRU is to an EXIT paragraph. What is the EVALUATE statement? EVALUATE is the alternative to the nested IF statements and is used to select from a list of processing actions. WHEN is used instead of IF to determine if the action is to be taken. Like the IF statement, the WHEN statement should be coded from the most likely to the least likely occurrence. Like the nested IF, once the condition is true, control passes from evaluate statement to the next statement in the program. What are the two most common forms of the EVALUATE statement? The two most common forms of the EVALUATE statement are :

Q.3 A

Q.5 A

Q.6 A

Q.7 A

Q.8 A

Page 1 of 11

1. 2. Q.9 A Q.10 A Q.11 A Q.12 A

EVALUATE TRUE, which allows multiple variables to be checked for a true condition. The list of options being tested must be prioritized, as the EVALUATE statement selects only the first TRUE condition per statement. EVALUATE VARIABLE-NAME checks multiple options for TRUE condition of a variable.

What does the INITIALIZE statement do? The INITIALIZE statement initializes data areas to zeros and spaces. How can you use INITIALIZE for specifying specific values? INITIALIZE GROUP-ITEM REPLACING ALPHANUMERIC DATA By HIGH-VALUES. When the REPLACING option is used, only specific type will be initialized. What is reference modification? Reference modification is the name for substring manipulations. The : allows part of a data item to be used without defining data item in the data division. Give two examples of how you would use reference modification? 1. In a list of ZIP codes, the first three digits define a geographic area :
IF ZIP ( I : 3 ) = '100' AREA = MANHATTAN END - IF

2. Q.13 A Q.14 A Q.15 A Q.16 A

MOVE 'MEXICO' TO STATE ( 5 : 6 ) could change NEW JERSEY to NEW MEXICO.

What is a nested program? A nested program is a program that allows coding of multiple procedure division within a single program. It is like a CALL, but it is more efficient. What is the difference between a directly contained and an indirectly contained program in a nested program? A directly contained program is in the next-lower nesting, while the indirectly contained program is more than one nesting below. Can there be a problem using ROUNDED in a compute statement? Yes. The compute rounds each intermediate result in a compute statement and not just the final result. Name some of the advantages of COBOL II? VS-COBOL II makes the operation of computer programs more efficient : It allows code to be shared. It optimizes code. It allows faster sorting. It eases program bugging and maintenance namely : Supports a debugging tool: COBTEST. Program listings provide information in a user-oriented way. Formatted dumps display status of programs and files in COBOL format, including data names and content. VS-COBOL/CICS interaction is easier to work with because of defined interfaces. What are VS-COBOL II special features?

Q.17

COBOL/COBOL II Questionnaire

The support of 31-bit addressing permits programs to operate above the line and to use larger tables in larger programs. This added space allows VSAM buffers to be placed above the 16-meg line, therefore the buffer can be larger. What options have been removed in COBOL II? COBOL II does not support ISAM and BDAM access methods and clauses which are specific to them. In addition, the following have been eliminated such as : REPORTWRITER EXAMINE TRANSFORM READY TRACE and RESET TRACE REMARKS paragraph and NOTES statement The ON statement (ON 1 PERFORM ...) What is a nested-copy statement? Independent blocks of code can be copied into the main sections of a program during compilation. COBOL II allows copied code to copy other code. What is an example of application efficiency provided by COBOL II? COBOL II will allow a program to be compiled as RE-ENTRANT. A re-entrant program can be placed in a shared virtual storage area, so that one copy of program is used to satisfy all concurrent requests for the program. What is COBTEST? COBTEST is a debugging tool for examining, monitoring and controlling VS-COBOL II programs in a test environment. Programs can be debugged by using a full-screen interactive mode, as well as a line interactive or batch mode. DATA may be altered, logic may be changed and results can be viewed on-line. How has the return code for VSAM files been changed in COBOL II? The return code has been enlarged to 6 bytes and returns the VSAM return code when the FILE STATUS is not 00. The format of the expanded return code is as follows : REGISTER 15 Return Code PIC 9(2) COMP. FUNCTION CODE PIC 9(1) COMP. FEEDBACK CODE PIC 9(3) COMP. What type of documentation would you recommend for a COBOL program? Document code changes at the beginning of the Program. The documentation should include chronological references following the date compiled statement and should include date in a fixed position and a brief description of the change in a fixed position. Programming techniques such as the use of copybooks, meaningful variable name, use of 88 levels and top-down code also provide informative documentation.

Q.18 A

Q.19 A Q.20 A

Q.21 A

Q.22 A

Q.23 A

Q.24 A Q.25 A

What is the file organization clause? The file organization clause identifies logical structure of a file. Can the logical structure of a file be changed once it has been created? No.

Page 3 of 11

Q.26 A Q.27 A

What is file organization indexed? The file organization indexed is where the position of each logical record within a file is determined by indexes created with the file and embedded in a key in each record. What is file organization sequential? The file organization sequential indicates that records are loaded into a file based on a record-to-record relationship of data sequence. Sequential is the default file organization. What is file organization relative? The position of each logical record in the file is determined by its relative record number. What is the dynamic access mode? The dynamic access mode permits reading and writing file records by a specific read or write statement which can be sequential and/or random. The dynamic access mode assumes that a file is indexed. What access modes are permitted with sequential organization? The sequential access mode only. What access modes are permitted with indexed organization? All three access modes-sequential, random and dynamic-are permitted. In dynamic access mode, the file can be accessed sequentially and/or randomly. What access modes are permitted with relative organization? All three access modes-sequential, random and dynamic-are permitted. What is a START statement? The START statement is used with an indexed or relative organization file for positioning within the file for subsequent sequential record retrieval. The access key may be qualified to provide a record equal to the key, greater than the key, less than the key, greater than or equal to the key. Who t is a subscript? A subscript is a positive integer that represents an occurrence within a table that has been redefined with an occurs clause. A subscript must be defined in working storage and can be manipulated like any numeric variable. What is an index for tables? An index references data in a table, but does it differently than a subscript. The index is defined with the table and represents a displacement into the table. What are the advantages of indexes? Indexes are more efficient when used with the SEARCH verb because the computer does not have to generate displacement from the beginning of the table. What are two SEARCH techniques? The sequential or serial search moves through a table one record at a time until a match has been made. For example, in a table of 10 numbers (1 to 10), to find the number 8, the search must check and eliminate numbers 1 to 7. The process is initiated by verb SEARCH.

Q.28 A Q.29 A

Q.30 A Q.31 A Q.32 A Q.33 A

Q.34 A

Q.35 A Q.36 A Q.37 A

COBOL/COBOL II Questionnaire

The binary is a dichotomizing search and must have a key that is in ascending or descending order. At each step of search, half of the records in the table are eliminated. For example, in SEARCH for the number 8, the first division would locate the number 5 and eliminate records 1 to 5. The second division would locate the number 8. The process is initiated by the very SEARCH ALL. Q.38 A Q.39 A What COBOL verbs can change table indexes? SET, SEARCH and PERFORM can change the value of a table index. Is a binary search efficient when compared to a sequential search? The binary search is more efficient because it finds the answer with fewer data checks. However the process for each data check is less efficient because of the machine code generated. If the list/table of variables has fewer than 100 entries, a sequential search would be a better choice. What is the most efficient method for locating data in a table? If you know the location of the data in the table, use it. For example, in a table of names of months, use numeric value of the month to locate the name. To convert 04/01/93 to April 01 1993, the 04 would be used as the subscript to locate the word April. How could one subscript sequentially through a table of 50 states, looking for NY? Given the subscript SUB-1 PIC 99, the following COBOL II code could be used :
PERFORM TABLE - LOOK - UP THRU TABLE - EXIT VARYING SUB 1 FORM 1 BY 1 UNTIL SUB - 1 > 50 OR MATCH - FOUND. CONTINUE 1. (CONTINUE WITH PROGRAM) TABLE - LOOK - UP. IF STATE (SUB - 1) = NY SET MATCH - FOUND TO TRUE MOVE TABLE-DATA (SUB-1) TO OUTPUT DATA END-IF TABLE - EXIT. EXIT.

Q.40 A

Q.41 A

Q.42

Recode the foregoing table lookup using an in-line perform.


PERFORM VARYING SUB - 1 FROM 1 BY 1 UNTIL MATCH - FOUND OR SUB - 1 > 50 IF STATE (SUB - 1) = NY SET MATCH - FOUND TO TRUE MOVE TABLE - DATA (SUB - 1) TO OUTPUT - DATA END - IF. END - PERFORM.

Q.43

Give answer to the previous question using a binary search, given the 01 level table name as 01 TABLE-NAME, the occurs clause indexed by table-index, ascending key is table-item.
SEARCH ALL TABLE - NAME AT END MOVE FILE-ITEM NOT FOUND TO FILE - ITEM - DESC WHEN TABLE - ITEM (TABLE - INDEX) EQUALS FILE - ITEM

Page 5 of 11

MOVE TABLE - ITEM - A (TABLE - ITEM) TO FILE - ITEM - DESC END - SEARCH.

Q.44 A

Describe a paragraph - naming convention that would assist navigation through a COBOL program? Paragraph names should be descriptive of what is contained within the paragraph and preceded by a sequential number according to their position within the program. For example :
100 - OPEN - FILLS; 500 - READ MASTER etc,

Q.45 A

What is one major advantage of COBOL II when operating in an MVS/XA environment? COBOL II can utilize 31-bit addressing and therefore operate above the line (above 17MB virtual memory restriction) in an MVS/XA environment-an advantage not available in VS-COBOL. What is the format of a COBOL internal sort using an input procedure and an output procedure?
SELECT SORT-FILE SD SORT - FILE SORT RECORD IS SORT - WORk - RFC. 01 SORT - WORK REC. 05 SORT-DATA. 07 DATA - PART - 1 07 FIRST - SORT - KEY

Q.46 A.

PIC X(10). PIC X(5).

(continue with record description for fields necessary for sorting and

fields to be sent to sort, the entire record need to be sorted unless required by the program)
PROCEDURE DIVISION. SORT SORT - FILE ASCENDING KEY FIRST - SORT - KEY INPUT PROCEDURE SORT - INPUT - PROCEDURE - 0200 OUTPUT PROCEDURE SORT - OUTPUT - PROCEDURE - 0500 SORT - INPUT - PROCEDURE - 0200 SECTION. SORT - INPUT - READ - SELECT.

fuse the input procedure to read the file to be sorted, select all or portion of data, process the data in any way and move the data to the sort - work - rec for subsequent release to the sort.)
RELEASE SORT - WORK - REC. SORT - OUTPUT - PROCEDURE - 0500 SECTION. SORT - OUTPUT - PROCESSING. (use the output procedure to return and process the sorted records) RETURN SORT - FILE AT END ...

Q.47

What are come advantages of a COBOL internal sort?

COBOL/COBOL II Questionnaire

A.

The advantages of a COBOL internal sort are : You can select only the records required by the program, reducing sort resource requirements Records can be processed before and after the sort One or more sorts may be performed on the same data for different functions within the program The program will document the criteria for record selection and sort criteria Data from separate files can be combined Is the SORT utility a responsible alternative to the internal sort? The sort utility would require an extra step in the JCL and would select, sort and document criteria. It could not manipulate the data before sort. The final decision depends on installation standards. What is a bubble sort? A bubble sort is an efficient way of resequencing a small table that already resides in memory. The sorting algorithm that can be used is referred to as a bubble sort. The bubble sort compares the key of first item in a table with the keys of all other items in the table, each time moving the item with the lowest key to the first items position. The process is continued, starting with the second item, comparing it to the third item, swapping pairs of items until the entire table is in order. What is an in-line perform? COBOL II allows a performed procedure to be, coded in-line. The perform statements is coded without a paragraph name, followed directly by the code to be performed. An END - PERFORM statement is required and coded at the end of an in-line perform.
PERFORM : END - PERFORM

Q.48 A.

Q.49 A.

Q.50 A

Q.51 A

What Is COBOL II statement WITH TEST AFTER? In a PERFORM, the UNTIL clause is examined before the PERFORM, not after. COBOL II allows programmer to specify PERFORM WITH TEST AFTER, which will always execute a paragraph at least once. How could 88 levels be used for validation of data for valid values and valid ranges? The 88 level is used to specify the valid values and/or rings of values and then the 88 data name is used in an if statement to test the data. Give an example of how you would code an 88.
02 INPUT - LOCATION PICTURE 9(3). 88 VALID - LOCATIONS VALUES ARE 100, 200 THRU 299.

Q.52 A. Q.53 A Q.54 A

How could 88 levels be used to determine the next step in navigating through a program? The 88-level data name can be used to specify a condition in both if and evaluate statements.
IF VALID - LOCATIONs PERFORM PARA - A END - IF

Page 7 of 11

EVALUATE TRUE WHEN VALID -LOCATIONS PERFORM PARA - A WHEN OTHER PERFORM PARA - B END-EVALUATE

Q.55 A Q.56 A Q.57 A Q.58 A Q.59 A Q.60 A

What is a CALL statement in COBOL? A CALL is a statement that transfers control from one object program to another object program within the same run-unit.. What does the COBOL CANCEL statement do? The CANCEL statement ensures that next time the referenced sub- program is called it will be entered in its original state. What is the LINKAGE SECTION in COBOL? The LINKAGE SECTION of a called program defines the data that is available (from a calling program) to a called program. Which program can reference the data items described in the LINKAGE SECTION? The data items in a LINKAGE SECTION may be referenced by the calling program as well as by the called program. What is the USING phrase of CALL statement? The USING phrase makes available data items from calling to the called programs. When can the USING phrase be included in the CALL statement? The USING phrase can be included in the CALL statement only if there is a USING phrase in the Procedure Division header or the ENTER statement through which the called program is invoked. Can the number of operands in the USING phrase in called program be different than the number of operands in the USING statement of calling programs? The number of operands in the calling program USING phrase and the called program USING phrase must be identical. How do file operands of the calling program USING phrase align with the operands of the called program USING phrase? The correspondence is by position - not by name. Can a called program contain CALL statements? Yes. However, a called program may not CALL the calling program directly or indirectly. What is a COPY statement? The COPY statement copies existing text from a copy library into a COBOL program. For example :
COPY text - name.

Q.61 A Q.62 A Q.63 A: Q.64 A

Q.65 A.

What is a copy library? A copy library is basically a COBOL source library containing members that can be, copied into COBOL source programs.

COBOL/COBOL II Questionnaire

Q.66 A.

What type of text can be copied using the COPY statement? The type of text that can be copied into a COBOL program includes all types of components of a COBOL program, including file definitions, working storage and procedure division code. What is the REPLACING option of a COPY statement? The REPLACING option of a COPY statement contains two operands and performs the COPY, replacing all occurrences of the first operand within the copied library member text by the second operand. Can the text of a copy library member contain nested COPY statements? In COBOL II a copy library member may contain nested COPY statements. This is not the case in VS-COBOL. Can a copy member with nested COPY statements contain the REPLACING option? No, a nested COPY statement cannot contain the REPLACING option. Can a COPY statement with the REPLACING option contain nested COPY statements? No, a COPY statement with the REPLACING option cannot contain nested COPY statements. What are some advantages to using COPY statements? An installation can develop standard file descriptions and mandate their use for standardization and ease of testing and maintenance. Also, standard working storage descriptions, record descriptions and procedure division code can be developed, enhancing development and maintenance efforts. What is the BY CONTENT phrase in COBOL II? The BY CONTENT phrase permits constants to be passed to a called program by using the CALL statement. What is the BY CONTENT LENGTH phrase in COBOL II? The BY CONTENT LENGTH phrase permits the length of a data item to be passed to a called program by using the CALL statement. What is the PICTURE clause? The PICTURE clause defines an elementary items basic characteristics and editing requirements. What would be the result of moving 030193 to a PICTURE clause of PICTURE 99/99/99? The result would be 03/01/93 - but only if the month, day and year were moved separately. How are numbers stored in the computer? Each digit is stored in a single byte; the first 4 bits contain the zone. The last 4 bits contain the digit. For numbers the zone indicates positive numbers (a C or an F) and negative numbers (D).

Q.67 A

Q.68 A Q.69 A Q.70 A Q.71 A

Q.72 A Q.73 A: Q.74 A Q.75 A Q.76 A:

Page 9 of 11

Q.77 A: Q.78 A Q.79 A.

What is EBCDIC? EBCDIC is an acronym for Extended Binary Coded Decimal Interchange Code. In EBCDIC, how would the number 1234 be stored? The number 1234 would be stored as : Fl F2 F3 F4. What is packed decimal? It is a method of storing numbers in less space. The zone is eliminated from each of the digits except for the last digit which contains sign for number. Packed decimals are always stored in an even number of bytes and the last byte is always the sign. The number of bytes used is determined by adding 1 to the total bytes requested and dividing by 2. The answer is always an even number. How would the number +1234 be stored if a PIC clause of PICTURE S9(4) COMP-3 were used? The answer will use 3 bytes (4 + 1 = 5 / 2 = 2.5 or 3), so a leading 0 will pad the answer : 01234F. What are binary numbers? Binary numbers are strings of 0s and 1s which are stored in half word, full word, or double word, depending on the size of the number. Up to 4 digits are stored in 2 bytes or a half word. 5-9 digits are stored in 4 bytes or a word. 10-18 digits are stored in 8bytes or a double word. What is a common problem when doing a table lookup? The maximum occurrences of the table are exceeded as a result of exiting perform based on testing the subscript for "equal to" the maximum number of occurrences rather than "greater than" the number of occurrences. By manipulating subscript, the subscript can become greater than the maximum number of occurrences, permitting the perform to continue beyond bounds of the table. What will be the result of executing a VS-COBOL II program when a subscript exceeds the table limits? The table data overwrites program code and will continue to do so until there is an abend. The abend message will reference gibberish code rather than a subscript out of range. What will be the result of executing a VS-COBOL II program that was compiled with the SSRANGE option, when a subscript exceeds the table limits? The program will terminate. What is a common problem associated with reading a datafile in a test environment? A read is executed on a file that has not been opened by the program. What problem could occur when a file is read with an incorrect file definition? A data exception could occur causing the program to terminate. In a production environment, what should be programmed when an abnormal

Q.80 A Q.81 A

Q.82 A

Q.83 A

Q.84 A Q.85 A Q.86 A Q.87

COBOL/COBOL II Questionnaire

condition is encountered and it is undesirable to continue processing? The program should go to a programmed abnormal exit and pass a condition code to the job control language via. an installation standard abend procedure. The job control language should in turn test the condition code and force the job to terminate with an abnormal condition code.

Page 11 of 11