Q. What is the dynamic access mode?
A 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.
Q. What access modes are permitted with sequential organization?
A The sequential access mode only.
Q. What access modes are permitted with indexed organization?
A All three access modes-sequential, random and dynamic-are permitted. In dynamic access mode, the file can be accessed sequentially and/or randomly.
Q. What access modes are permitted with relative organization?
A All three access modes-sequential, random and dynamic-are permitted.
Q. What is a START statement?
A 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.
Q. Who t is a subscript?
A 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.
Q. What is an index for tables?
A 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.
Q. What are the advantages of indexes?
A 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.
Q. What are two SEARCH techniques?
A 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.
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. What COBOL verbs can change table indexes?
A SET, SEARCH and PERFORM can change the value of a table index.
Q. Is a binary search efficient when compared to a sequential search?
A 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.
Q. What is the most efficient method for locating data in a table?
A 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.
Q. How could one subscript sequentially through a table of 50 states, looking for NY?
A 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. 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. 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
MOVE TABLE - ITEM - A (TABLE - ITEM) TO FILE - ITEM - DESC
END - SEARCH.
Q. Describe a paragraph - naming convention that would assist navigation through a COBOL program?
A 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. What is one major advantage of COBOL II when operating in an MVS/XA environment?
A COBOL II can utilize 31-bit addressing and therefore operate “above the line” (above 17-MB virtual memory restriction) in an MVS/XA environment-an advantage not available in VS-COBOL.
Q. What is the format of a COBOL internal sort using an input procedure and an output procedure?
A. SELECT SORT-FILE
SD SORT - FILE
SORT RECORD IS SORT - WORk - RFC.
01 SORT - WORK REC.
05 SORT-DATA.
07 DATA - PART - 1 PIC X(10).
07 FIRST - SORT - KEY 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. What are come advantages of a COBOL internal sort?
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
Q. Is the SORT utility a responsible alternative to the internal sort?
A. 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.
Q. What is a bubble sort?
A. 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 item’s 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.
Q. What is an in-line perform?
A 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. What Is COBOL II statement WITH TEST AFTER?
A 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.
Q. How could 88 levels be used for validation of data for valid values and valid ranges?
A. 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.
Q. Give an example of how you would code an “88”.
A 02 INPUT - LOCATION PICTURE 9(3).
88 VALID - LOCATIONS VALUES ARE 100, 200 THRU 299.
Q. How could 88 levels be used to determine the next step in navigating through a program?
A 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
EVALUATE TRUE
WHEN VALID -LOCATIONS
PERFORM PARA - A
WHEN OTHER
PERFORM PARA - B
END-EVALUATE
Q. What is a CALL statement in COBOL?
A A CALL is a statement that transfers control from one object program to another object program within the same run-unit..
Q. What does the COBOL “CANCEL” statement do?
A The CANCEL statement ensures that next time the referenced sub- program is called it will be entered in its original state.
Q. What is the LINKAGE SECTION in COBOL?
A The LINKAGE SECTION of a called program defines the data that is available (from a calling program) to a called program.
Q. Which program can reference the data items described in the LINKAGE SECTION?
A The data items in a LINKAGE SECTION may be referenced by the calling program as well as by the called program.
Q. What is the USING phrase of CALL statement?
A The USING phrase makes available data items from calling to the called programs.
Q. When can the USING phrase be included in the CALL statement?
A 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.
No comments:
Post a Comment