COBOL Interview Questions Answers PART-2
What is the difference between search and search all in the table handling?
Ans: Search is a linear search and search all is a binary search.
WHAT IS REPORT-ITEM?
Ans: A REPORT-item is a field to be printed that contains EDIT SYMBOLS
You are writing report program with 4 levels of totals:city,state,region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code show. Do you do your checking for breaks and how do you do add to each level?
Ans: Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each rec but add to the higher level only on break.
What is the Importance of GLOBAL clause According to new standards of COBOL
Ans: When any data name, file-name , Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 PIC 9(5) IS GLOBAL.
What is the Purpose of POINTER Phrase in STRING command
Ans: The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
How do we get currentdate from system with century?
Ans: By using Intrinsic function, FUNCTION CURRENT-DATE
What is PSB & ACB?
Ans: PSB : Program specification block. Inform about how a specific program is to be access one or more IMS DB. It consists of PCB(Prg Communication Block). Information to which segment in DB can be accessed, what the program is allowed to do with those segment and how the DB is to be accessed. ACB : Access Control Blocks are generated by IMS as an expansion of information contained in the PSB in order to speed up the access to the applicable DBD's.
What is the difference between a DYNAMIC and STATIC call in COBOL.
Ans: To correct an earlier answer:All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. DYNAMICally called modules are those that are not bound with the calling program at link edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the linkage editor will not generate an executable as it will expect null address resolution of all called modules. A STATICally called module is one that is bound with the calling module at link edit, and therefore becomes part of the executable load module.
What is the maximum length of a field you can define using COMP-3?
Ans: 10 Bytes (S9(18) COMP-3).
How many Sections are there in Data Division?.
Ans: SIX SECTIONS 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'SCREEN SECTION' 5.'REPORT SECTION' 6.'LINKAGE SECTION'
In COBOL II, there are only 4 sections. 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'LINKAGE SECTION'.
How can I tell if a module is being called DYNAMICALLY or STATICALLY?
Ans: The ONLY way is to look at the output of the linkage editor (IEWL)or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal (CALL).
What's a LDS(Linear Data Set) and what's it used for ?
Ans: LDS is a VSAM dataset in name only. It has unstructured 4k (4096 bytes) fixed size CIs which do not contain control fields and therefore from VSAM's standpoint they do not contain any logical records. There is no freespace, and no access from Cobol. Can be accessed by DB2 and IMS fast path datasets. LDS is essentially a table of data maintained on disk. The 'table entries' must be created via a user program and can only be logically accessed via a user program. When passed, the entire LDS must be mapped into storage, then data is accessed via base and displacement type processing.
What is Pic 9v99 Indicates?
Ans: PICTURE 9v99 is a three position Numeric field with an implied or assumed decimal point after the first position; the v means an implied decimal point.
What guidelines should be followed to write a structured COBOL program?
Ans:
1) Use 'EVALUATE' stmt for constructing cases.
2) Use scope terminators for nesting.
3)Use in-line Perform stmt for writing 'do ' constructions.
4) Use Test Before and test after in the Perform stmt for writing Do-While constructions.
Read the following code.
01 ws-n PIC 9(2) value zero.
a-para.
move 5 to ws-n.
perform b-para ws-n times.
b-para.
move 10 to ws-n.
How many times will b-para be executed ?
Ans: 5 Times only. it will not take the value 10 that is initialized in the loop.
What is the difference between PIC 9.99 and 9v99?
Ans: PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE-POSITION numeric field with implied or assumed decimal position.
How is PIC 9.99 is different from PIC 9v99?
Ans: PIC 9.99 is a four position field that actually contains a decimal point where as 9v99 is a three position numeric field with an implied or assumed decimal point.
What is the difference between search and search all in the table handling?
Ans: Search is a linear search and search all is a binary search.
WHAT IS REPORT-ITEM?
Ans: A REPORT-item is a field to be printed that contains EDIT SYMBOLS
You are writing report program with 4 levels of totals:city,state,region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code show. Do you do your checking for breaks and how do you do add to each level?
Ans: Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each rec but add to the higher level only on break.
What is the Importance of GLOBAL clause According to new standards of COBOL
Ans: When any data name, file-name , Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 PIC 9(5) IS GLOBAL.
What is the Purpose of POINTER Phrase in STRING command
Ans: The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
How do we get currentdate from system with century?
Ans: By using Intrinsic function, FUNCTION CURRENT-DATE
What is PSB & ACB?
Ans: PSB : Program specification block. Inform about how a specific program is to be access one or more IMS DB. It consists of PCB(Prg Communication Block). Information to which segment in DB can be accessed, what the program is allowed to do with those segment and how the DB is to be accessed. ACB : Access Control Blocks are generated by IMS as an expansion of information contained in the PSB in order to speed up the access to the applicable DBD's.
What is the difference between a DYNAMIC and STATIC call in COBOL.
Ans: To correct an earlier answer:All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. DYNAMICally called modules are those that are not bound with the calling program at link edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the linkage editor will not generate an executable as it will expect null address resolution of all called modules. A STATICally called module is one that is bound with the calling module at link edit, and therefore becomes part of the executable load module.
What is the maximum length of a field you can define using COMP-3?
Ans: 10 Bytes (S9(18) COMP-3).
How many Sections are there in Data Division?.
Ans: SIX SECTIONS 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'SCREEN SECTION' 5.'REPORT SECTION' 6.'LINKAGE SECTION'
In COBOL II, there are only 4 sections. 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'LINKAGE SECTION'.
How can I tell if a module is being called DYNAMICALLY or STATICALLY?
Ans: The ONLY way is to look at the output of the linkage editor (IEWL)or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal (CALL).
What's a LDS(Linear Data Set) and what's it used for ?
Ans: LDS is a VSAM dataset in name only. It has unstructured 4k (4096 bytes) fixed size CIs which do not contain control fields and therefore from VSAM's standpoint they do not contain any logical records. There is no freespace, and no access from Cobol. Can be accessed by DB2 and IMS fast path datasets. LDS is essentially a table of data maintained on disk. The 'table entries' must be created via a user program and can only be logically accessed via a user program. When passed, the entire LDS must be mapped into storage, then data is accessed via base and displacement type processing.
What is Pic 9v99 Indicates?
Ans: PICTURE 9v99 is a three position Numeric field with an implied or assumed decimal point after the first position; the v means an implied decimal point.
What guidelines should be followed to write a structured COBOL program?
Ans:
1) Use 'EVALUATE' stmt for constructing cases.
2) Use scope terminators for nesting.
3)Use in-line Perform stmt for writing 'do ' constructions.
4) Use Test Before and test after in the Perform stmt for writing Do-While constructions.
Read the following code.
01 ws-n PIC 9(2) value zero.
a-para.
move 5 to ws-n.
perform b-para ws-n times.
b-para.
move 10 to ws-n.
How many times will b-para be executed ?
Ans: 5 Times only. it will not take the value 10 that is initialized in the loop.
What is the difference between PIC 9.99 and 9v99?
Ans: PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE-POSITION numeric field with implied or assumed decimal position.
How is PIC 9.99 is different from PIC 9v99?
Ans: PIC 9.99 is a four position field that actually contains a decimal point where as 9v99 is a three position numeric field with an implied or assumed decimal point.