COBOL经典面试题库(中英文版)

来源:互联网 发布:阿里云 爬虫 编辑:程序博客网 时间:2024/04/28 01:54

 COBOL经典面试题库(中英文版) 收藏
Q1) Name the divisions in a COBOL program ?.
A1) IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.
Q:列举COBOL的DEVISION
A:标识部,环境部,数据部,过程部

Q2) What are the different data types available in COBOL?
A2) Alpha-numeric (X), alphabetic (A) and numeric (9).
Q:COBOL有哪些可用的数据类型
A:字符型(这里指的是包含字母和数字),字母型,数字型

Q3) What does the INITIALIZE verb do? - GS
A3) Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched.
Q:INITIALIZE这个词做了些什么
A:将字母,字符,数字区域都置成空格(置空),将数字区置0, FILLER和OCCURS DEPENDING ON项不处理

Q4) What is 77 level used for ?
A4) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
Q:77层有什么作用
A:基本层数据项,不能用做细分别的层,也不能被细分

Q5) What is 88 level used for ?
A5) For condition names.
Q:88层有什么作用
A:条件逻辑层

Q6) What is level 66 used for ?
A6) For RENAMES clause.
Q:66层有什么作用
A:重命名层

Q7) What does the IS NUMERIC clause establish ?
A7) IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .
Q:IS NUMERIC这个子句怎么确定(也就是说确定句子的真值)
A:IS NUMERIC用在字符项,带符号数字,浮点数,不带符号数。如果目标项只含0~9则返回TRUE。但是,如果待测项目是个带符号数,那么他就含有0-9还有+和-

Q8) How do you define a table/array in COBOL?
A8) ARRAYS.
05 ARRAY1 PIC X(9) OCCURS 10 TIMES.
05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX
Q:COBOL中怎么建表/数组
A:如上.

Q9) Can the OCCURS clause be at the 01 level?
A9) No.
Q:OCCURS 子句能用在第一层吗
A:不能

Q10) What is the difference between index and subscript? - GS
A10) Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the
array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to
use SEARCH, SEARCH ALL.
Q:索引和下标有什么区别
A:下标可以指定数组中任意中位置的元素(只要知道其下标),下标只能是数字型常量或者数字型变量(但是不能在指定的时候修改,如:A(K+1)这样是不行的,要修改的话要在指定的外部改,如:ADD 1 TO K,而索引的话是从表头/数组头开始检索(以BY N的指定检索规律往后滚)
再者,索引只能通过PERFORM, SEARCH 和SET来修改,如果要在一个表中使用SEARCH, SEARCH ALL,那这个表就要有索引(因为SEARCH, SEARCH ALL的参数中指定索引,所以即使其有很多限制还是得用它)

Q11) What is the difference between SEARCH and SEARCH ALL? - GS
A11) SEARCH - is a serial search.
SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.
Q:SERACH和SERACH ALL有什么区别
A:SEARCH是顺序查找
SERACH ALL 是2叉查找(相信数据结构学过2叉树的都不会陌生),在使用SEARCH ALL前表必须有一个递增/递减的KEY,并且表已经按照其KEY值排序了,这样才能使用SEARCH ALL

Q12) What should be the sorting order for SEARCH ALL? - GS
A12) It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an
array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You
must load the table in the specified order).
Q:为了使用SEARCH ALL,存贮顺序是怎么样的
A:他必须是递增或者是递减的,默认地政。如果你想在一个递减顺序存贮的表/数组使用搜索的话,那么当定义表/数组的时候你应该加一个DESCENDING KEY子句(这之前表要已经按指定的顺序排序了)

Q13) What is binary search?
A13) Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.
Q:什么是2叉查找
A:将你要找的目标项与数组的正中项比较,找到就结束搜索,没找到则继续如此循环(比较下一个中值),取哪一半取决于目标值大于中值还是小于中值
PS:联想2叉树的查找规律就很好理解,因为所谓的“表“本身也就是数组

Q14) My program has an array defined to have 10 items. Due to a bug, I find that even if the program access the
11th item in this array, the program does not abend. What is wrong with it?
A14) Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
Q:我的程序有个数组定义了10项。因为有个BUG,我发现即使访问第11项,程序也不异常终止。那是出了什么问题
A:必须使用编译器的一个选项SSRANGE,如果你想检查数组的超界问题。默认是NOSSRANGE

Q15) How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning. - GS
A15) Syntax: SORT file-1 ON ASCENDING/DESCENDING KEY key…. USING file-2 GIVING file-3.

USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.

file-1 is the sort (work) file and must be described using SD entry in FILE SECTION.
file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT
clause in FILE CONTROL.
file-3 is the out file from the SORT and must be described using an FD entry in FILE SECTION and SELECT
clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.

INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.
Q:怎么在一个COBOL程序中排序?给出排序文件的定义,排序语法和意思
A:语法就是SORT file-1 ON ASCENDING/DESCENDING KEY key…. USING file-2 GIVING file-3.
USING后程序的输入接口,这个地方可以替换成一个输出过程,也就是说写一个过程往USING这个接口中导数据(要在这个过程中READ,AT END,……),这个过程在将数据释放到执行排序的文件中之前执行,GIVING后是输出借口,用法类似。
此例中输入文件是file-2输出文件是file3(这样个文件必须在文件区中用FD和在文件控制中用到SELECT)真正执行排序的file-1,这里需要注意的是file-1中的文件区不能用FD,应该用SD,file-2和3还是一样(用FD),具体可以看一下书上的例子

Q16) How do you define a sort file in JCL that runs the COBOL program?
A16) Use the SORTWK01, SORTWK02,….. dd names in the step. Number of sort datasets depends on the volume of data
being sorted, but a minimum of 3 is required.
Q:怎么在JCL中定义一个排序文件来跑这个COBOL程序
A:用SORTWK01, SORTWK02,…..作为DATA SET NAME。用多少取决于你要排序的数量,但是至少3个。

Q17) What is the difference between performing a SECTION and a PARAGRAPH? - GS
A17) Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.
Q:执行一个区和一个段有什么区别
A:简单来说的话就是区的概念比段大,执行一个区就要执行其内部所有段,执行段的话只执行该段。

Q18) What is the use of EVALUATE statement? - GS
A18) Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and
case is that no ‘break’ is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is
made.
Q:EVALUATE语句有什么作用
A:EVALUATE就象个CASE语句(多重开关语句,学过C的总知道吧),不同点在于EVALUATE不需要BREAK,一旦匹配就跳出EVALUATE语句了

Q19) What are the different forms of EVALUATE statement?
A19)
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS
WHEN A=B AND C=D WHEN 100 ALSO ‘00′
imperative stmt imperative stmt
WHEN (D+X)/Y = 4 WHEN -305 ALSO ‘32′
imperative stmt imperative stmt
WHEN OTHER WHEN OTHER
imperative stmt imperative stmt
END-EVALUATE END-EVALUATE

EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE
WHEN 100 ALSO TRUE WHEN 100 ALSO A=B
imperative stmt imperative stmt
WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)
imperative stmt imperative stmt
END-EVALUATE END-EVALUATE

Q20) How do you come out of an EVALUATE statement? - GS
A20) After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the
EVALUATE statement. There is no need of any extra code.
Q:怎么跳出一条EVALUATE语句
A:象18题目说的那样,一旦匹配了某一个“WHEN“语句就自动跳出了,不需要什么额外的代码来跳出

Q21) In an EVALUATE statement, can I give a complex condition on a when clause?
A21) Yes.
Q:在一个EVALUATE语句的某个WHEN分支中能否再插入复杂的情况(也就是嵌套)
A:当然可以,当多个参数作为控制变量的时候1个WHEN内部可以嵌套更多的情况

Q22) What is a scope terminator? Give examples.
A22) Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.
Q:什么是结束终止符
A:结束终止符是搭配一些范围指令的,也就是标识一些范围指令的结束。如:EVALUATE, END-EVALUATE; IF, END-IF 如果没有该结束符,该条语句将终止不了

Q23) How do you do in-line PERFORM? - GS
A23) PERFORM … …

END-PERFORM
Q:怎么使用内嵌的PERFORM
A:PERFORM … …

END-PERFORM
所谓内嵌也就是PERFORM被嵌在某些比如循环语句中担当执行主体,同时通过UNTIL来指定结束判定

Q24) When would you use in-line perform?
A24) When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code
(used from various other places in the program), it would be better to put the code in a separate Para and use
PERFORM Para name rather than in-line perform.
Q:什么时候使用内嵌式PERFORM
A:当该段PERFORM的内容不被其他段用到,只在某些局部代码中(当然PERFORM的主体所用到的参数也都是局部的,例如循环)使用,如果PERFORM主体的代码是一般的(用到了别的程序段的变量),还是使用PERFORM Para name这样的形式比较好(也就是相对与内于PERFORM的外部PERFORM)。

Q25) What is the difference between CONTINUE & NEXT SENTENCE ?
A25) They appear to be similar, that is, the control goes to the next sentence in the paragraph. But, Next Sentence would
take the control to the sentence after it finds a full stop (.). Check out by writing the following code example, one if
sentence followed by 3 display statements (sorry they appear one line here because of formatting restrictions) If 1 > 0
then next sentence end if display ‘line 1′ display ‘line 2′. display ‘line 3′. *** Note- there is a dot (.) only at the end of
the last 2 statements, see the effect by replacing Next Sentence with Continue ***
Q:CONTINUE 和 NEXT SENTENCE有什么不同
A:两者比较相似,都是将程序控制权交给下一句,但是用NEXT SENTENCE的时候,只有当碰到句结束符(就是句末的‘.’)才会将执行下句
这道题我用了2个例子测试了一下:
1:IF TEST-NUMERIC > 0
THEN NEXT SENTENCE
END-IF
DISPLAY ‘LINE1′ DISPLAY ‘LINE2′. DISPLAY ‘LINE3′.(请注意代码中的‘.’号)
结果输出:LINE3
2:IF TEST-NUMERIC > 0
THEN CONTINUE
END-IF
DISPLAY ‘LINE1′ DISPLAY ‘LINE2′. DISPLAY ‘LINE3′.
结果输出:LINE1
LINE2
LINE3
相信已经区别已经比较明显了,NEXT SENTENCE是靠句末的结束符(也就是‘.‘)来判断下一句的,而CONTINUE是通过句头的保留字(这例中是DISPLAY)来判断下一句的
Q26) What does EXIT do ?
A26) Does nothing ! If used, must be the only sentence within a paragraph.
Q:EXIT语句有什么作用
A:什么都不做,如果用到的话,肯定是作为一段的唯一的一句话,注意:这里不是子程序中用的EXIT PROGRAME

Q27) Can I redefine an X(100) field with a field of X(200)?
A27) Yes. Redefines just causes both fields to start at the same location. For example:

01 WS-TOP PIC X(1)
01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).
If you MOVE ‘12′ to WS-TOP-RED,
DISPLAY WS-TOP will show 1 while
DISPLAY WS-TOP-RED will show 12.
Q:能不能把X(100)的区域重定义成X(200)
A:可以,重定义只是相当于把两个区域的首地址放在一起,从上面这个例子也很好理解

A28) Can I redefine an X(200) field with a field of X(100) ?
Q31)1 Yes.
Q:能不能把X(200)的区域重定义成X(100)
A:可以,原因同上

Q31)2 What do you do to resolve SOC-7 error? - GS
Q31) Basically you need to correcting the offending data. Many times the reason for SOC7 is an un-initialized numeric item.
Examine that possibility first. Many installations provide you a dump for run time abend’s ( it can be generated also
by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last
instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line
number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the
runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL. If none of these are helpful, use
judgement and DISPLAY to localize the source of error. Some installation might have batch program debugging
tools. Use them.
Q:怎么解决SOC-7错误
A:基本上你要看一下一些比较奇怪的数据,很多导致SOC7的原因都是因为数据项的初始化。
首先检查所有的可能性。某些功能可能提供一个空间用来存贮那些运行时间ABEND,并且提供最近一次运行时间ABEND的偏移量的说明(也就是位于队列中的位置),检查编译器的输出XREF队列以获得一些关键字。然后你就能看下源代码找出BUG。为了捕获一些运行时间的信息,你需要在JCL中建一个DATASET(象SYSABOUT这样的),如果这些都没用,那么再审查一下ERROR出现的位置判断一下原因。有些软件安装了会提供批处理程序调试工具,那么可以就可以用这些工具了。
PS:以上大意就是说SOC-7这个错误多半是因为数据项初始化造成的,然后你应该到运行后编译器的返回信息中去找这些ERROR出现的地方(我们常用的话应该就是走查LOG),查的时候多注意下数据项的初始化问题。

Q32) How is sign stored in Packed Decimal fields and Zoned Decimal fields?
Q32) Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.
Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.
Q:在内部十进制区域和显示十进制区域符号是怎么存贮的
A:内部十进制是一个数字占4位(半字节),内存中用16进制来存,最后在追加4位作为符号,如-4=01001101(末尾的1101表示负,1100表示正),而我们用于显示的十进制,符号并不占空间,只是在最后一位上标识一下

Q33) How is sign stored in a comp-3 field? - GS
Q33) It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if
your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc…
Q:COMP-3区怎么存储符号
A:COMP-3采用的是内部十进制的存储方式,所谓内部十进制就是压缩式的外部十进制存储方式,上题讲过外部十进制每个数值都用1个字节存储,但前4位是存符号的,这样比较浪费存储空间,所以内部十进制的存储方式就用半个字节(4位)存储一个数字,在最后增加4位作为符号(1100(C)为正,1101(D)为负)

Q34) How is sign stored in a COMP field ? - GS
Q34) In the most significant bit. Bit is ON if -ve, OFF if +ve.
Q:COMP区怎么存储符号
A:COMP是采用定点二进制的方式存储数据,也就是将一个十进制的数值转化成二进制再进行存储,因为机器存储的形式也是二进制,所以定点二进制的读取是最快速的,因为COMP型的数据是用做计算(也就是说不用再转化成十进制打印),使用定点二进制将会非常高效。这样的存储方式符号是保存在最高有效果位上,如:10=(00001010)₂,
-10=(00011010)₂

Q35) What is the difference between COMP & COMP-3 ?
Q35) COMP is a binary storage format while COMP-3 is packed decimal format.
Q:COMP和COMP-3什么区别
A:这之前讲过了,COMP采用定点二进制存储,COMP-3采用内部十进制存储

Q36) What is COMP-1? COMP-2?
Q36) COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.
Q:COMP-1是什么?什么是COMP-2
A:其实之所以定义计算型数据(COMP~COMP-3)以区别DISPLAY(能计算,但是要用于打印)是为了考虑效率,因为大家知道文件导入(也就是USER使用的数据)一般是十进制的,而机器存储都是二进制,那么当定义的数据光用来计算不用打印,处于效率考虑会把它定义成COMP型,当然就会衍生出几类COMP以适应不用的数据类型的存储。很明显,这里COMP-1就是采用内部短浮点(4个字节表示一个数,8位指数部分,24位表示数字部分),COMP-2用内部长浮点型(8个字节表示一个书,16位指数部分,48位表示数字部分)以适应浮点数据的存储,长浮点精确度更高.

Q37) How do you define a variable of COMP-1? COMP-2?
Q37) No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
Q:怎么定义一个COMP-1型?COMP-2型
A:不要用PICTURE描述,因为是确定分配多少内存的,直接用USAGE,如01 WS-VAR USAGE COMP-1

Q38) How many bytes does a S9(7) COMP-3 field occupy ?
Q38) Will take 4 bytes. Sign is stored as hex value in the last nibble. General formula is INT((n/2) + 1)), where n=7 in this
example.
Q:一个S9(7)的COMP-3型占用多少字节?
A:占用4字节。COMP-3用内部十进制存储,S9(7)中的S是要占空间的,符号占4位,7个数字,每个4位(半个字节),所以是(4+7*4)/8=4字节(字节和位的比例不要搞错了哦)

Q39) How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
Q39) Will occupy 8 bytes (one extra byte for sign).
Q:一个S9(7) SIGN TRAILING SEPARATE区域占多少字节
A:这里是每个符号单独分配空间(也就是没个数值用1个字节表示,就象最常用的DISPLAY型的分配方式),算上S的空间,所以是7+1=8字节。一般情况省略的SIGN子句都是隐含SIGN IS TRAILING的

Q40) How many bytes will a S9(8) COMP field occupy ?
Q40) 4 bytes.
Q: 一个S9(8) COMP 区域占多少字节
A:如果之前关于COMP的解释听懂了的话,那很显然就是4字节了(定点二进制用2字节存储1~4,4字节存储5~9,……类推,你可以自己推下),如果这块还不懂的可以问我或者查下书

Q41) What is the maximum value that can be stored in S9(8) COMP?
Q41) 99999999
Q:S9(8)COMP型最多存储的最大值是什么
A:除了8个数值外不要忽略符号位

Q42) What is COMP SYNC?
Q42) Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT. For binary data
items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main
frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my
first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start
from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4.
You might see some wastage of memory, but the access to this computational field is faster.
Q:COMP SYNC是什么
A:使数据项按“自然边界”排列。SYNCHRONIZED(简写SYNC)语句是同步安置语句。不同的机器会有一个机器字的概念(以一个WORD四个字节举例,这个数字因机器各异,但往往是四个字节),两个机器字之间就是这里说的“自然边界”,也就是说机器每次从内存中取出二个字节长度的数据,但是一个数据项中含有的数值可能跨越几个机器字或者未填满机器字,这样连续读取虽然比较省空间,但是要引用某些机器字的时候要把多个拿出来重新组织(因为一个数值可能跨越多个数据字,也可能未满,机器就要判断一个机器字中哪些是前一个数值哪些是下个数值)。如果向左对齐的话就是想左“自然边界”靠,也就是说未满一个数据字的用空格(对非数字项)或者零(数字项)填充,填充部分不能插入其他数据项的内容,同理向右对齐就是向机器字的右“自然边界”靠,类似的在左边的空余部分填充。按照自然边界存储相当与牺牲空间换取时间,存取效率,系统读取的机器字两段填充区域(0或者SPACE)之间就是一个数值,效率很高。

Q43) What is the maximum size of a 01 level item in COBOL I? in COBOL II?
Q43) In COBOL II: 16777215
Q:COBOL1定义的01层最大大小是多少,COBOL II中?
A:COBOL II中是16777215,没什么说的,自己翻书

Q44) How do you reference the following file formats from COBOL programs:
Q44)
Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
BLOCK CONTAINS 0 .
Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
do not use BLOCK CONTAINS
Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK
CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4
Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use
BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will
be max rec length in pgm + 4.
ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.
KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK
CONTAINS 0. (Use RECFM=FBA in JCL DCB).
Q:COBOL中如何涉及(引用调用)以下这些文件
A: 文件类型 这里是COBOL在文件控制区中的文件组织访问形式(SELECT下面那句)这里最好翻翻书或者事例代码反复记忆
定长文件 用 ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0
固定但是不是以块的组织形式 用 ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, 不要使用BLOCK CONTAINS(因为不是以块的组织形式)
变长文件 用 ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V,BLOCK ,CONTAINS 0.在之后的文件区中的文件描述FD中不要编码记录长度为4字节
变长但是不是以块的组织形式 用 ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V,同样不要使用BLOCK CONTAINS也不要编码记录长度为4字节(原因同上)
ESDS VSAM文件 用ORGANISATION IS SEQUENTIAL
KSDS VSAM文件 用ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD
作为关键字的RRDS文件 用ORGANISATION IS RELATIVE, RELATIVE KEY IS
打印文件 用ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB)
PS:这道题是阐述COBOL怎么调用外部的各种文件,在文件控制区以及文件区中要定义的一些关键字,有我们最熟悉的FB(定长)和VB(变长)(当然我们的前提是这两类都是以BLOCK(块)为单位的)但是也有不为我们所知的文件类型(可能出现的情况很少,但是也确实存在,比如编译出的MODULE放的LOAD必须是V文件(文件组织形式是V))当然在不写ORGANISATION这些关键字的时候都是默认为FB的,但是在处理一些复杂数据(比如VSAM数据)还有和外部文件(比如JCL)的连接的时候这些保留字都是要指定的,关于更具体的还是要翻书加强记忆

Q45) What are different file OPEN modes available in COBOL?
Q45) Open for INPUT, OUTPUT, I-O, EXTEND.
Q:COBOL中有哪些OPEN方式
A:有INPUT,OUTPUT,I-O,EXTEND这些OPEN模式

Q46) What is the mode in which you will OPEN a file for writing? - GS
Q46) OUTPUT, EXTEND
Q:当你想OPEN一个文件用来写入的时候,这属于什么方式
A:OUTPUT,EXTEND方式

Q47) In the JCL, how do you define the files referred to in a subroutine ?
Q47) Supply the DD cards just as you would for files referred to in the main program.
Q:JCL中怎么定义在子程序中要调用的文件
A:就象要在主程序中调用一样使用DD语句

Q48) Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?
Q48) Can rewrite (record length must be same), but not delete.
Q:能否REWRITE(重写)一个ESDS文件?能否删除ESDS中的一条记录?
A:能够重写(但是记录长度必须相同),但是不能删除

Q49) What is file status 92? - GS
Q49) Logic error. e.g., a file is opened for input and an attempt is made to write to it.
Q:文件状态92是什么?
A:是文件状态的一个返回码,是逻辑错误的意思,比如,打开了一个文件用来导入数据但是又想将其他数据写入这个文件

Q50) What is file status 39 ?
Q50) Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You
will get file status 39 on an OPEN.
Q:文件状态39是什么
A:当你的COBOL的逻辑记录长度(LRECL)或者块长度(BLOCKSIZE)或者记录形式(RECFM)和 JCL匹配错误,文件状态参数就会返回39

Q51) What is Static and Dynamic linking ?
Q51) In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
Q:什么是静态和动态连接
A:在静态连接中,被调用的子程序是连接到调用程序,但是在动态连接中,被调用子程序和调用主程序的可执行模块是都存在的(分开的)。你可以在连接选项中选择DYNAM或者NODYNAM(就算你选择了NODYNAM,CALL标识符还是回把它自动转换成一个动态调用)。静态子程序下次被调用时不会再处于其初始状态,除非用INITIAL初始化或者用CANCEL。动态的都是以初始状态存在的。

Q52) What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? (applicable to only MVS/ESA
Enterprise Server).
Q52) These are compile/link edit options. Basically AMODE stands for Addressing mode and RMODE for Residency
mode.
AMODE(24) - 24 bit addressing;
AMODE(31) - 31 bit addressing
AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.
RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs.
(OS/VS Cobol pgms use 24 bit addresses only).
RMODE(ANY) - Can reside above or below 16 Meg line.
Q:AMODE(24),AMODE(31),RMODE(24)和RMODE(ANY)是什么?(仅适用于MVS/ESA 企业管理器)
A:是编译/连接的选项卡。基本上AMODE表示寻址方式,RMODE 表示贮存方式。
AMODE(24):24位的寻址方式
AMODE(31):31位的寻址方式
AMODE(ANY):是用24位还是31位的寻址方式取决于REMODE
RMODE(24):存在虚存中超过16Meg lne(MEG LINE是某种单位)允许31位的程序调用24位的程序。(OS/VS COBOL的PGM只有24位的存址)
RMODE(ANY)-超过或者不到16Meg line

Q53) What compiler option would you use for dynamic linking?
Q53) DYNAM.
Q:如果要动态连接那么要用什么编译选项
A:DYNAM

Q54) What is SSRANGE, NOSSRANGE ?
Q54) These are compiler options with respect to subscript out of range checking. NOSSRANGE is the default and if chosen,
no run time error will be flagged if your index or subscript goes out of the permissible range.
Q:SSRANGE,NOSSRANGE是什么
A:这在之前已经提到过了,是编译器的一个选项,用来核对数组索引或者下标的超界问题(比如只定义了10个元素程序却使用了第11个元素的情况)默认情况下是NOSSRANGE,如果选了NOSSRANGE,那么当索引和下标超界的时候也不会报RUN TIME ERROR

Q55) How do you set a return code to the JCL from a COBOL program?
Q55) Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.
Q:怎么从一个COBOL程序设置一个JCL的返回码
A:把你想设置的值MOVE到RETURN-CODE这个寄存器中。RETURN-CODE寄存器并未在这COBOL程序中申明

Q56) How can you submit a job from COBOL programs?
Q56) Write JCL cards to a dataset with //xxxxxxx SYSOUT= (A,INTRDR) where ‘A’ is output class, and dataset should be
opened for output in the program. Define a 80 byte record layout for the file.
Q:怎么在COBOL程序中提交一个JOB
A:把一个JCL用“//xxxxxxx SYSOUT= (A,INTRDR)”写到一个DATASET中,A是输出组,在程序中要将这个DATASET作为OUTPUT(输出)打开。为这个文件定义一个80字节的记录格式长度

Q57) What are the differences between OS VS COBOL and VS COBOL II?
Q57) OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit
addressing modes.
I. Report writer is supported only in OS/VS Cobol.
II. USAGE IS POINTER is supported only in VS COBOL II.
III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II.
IV. EVALUATE is supported only in VS COBOL II.
V. Scope terminators are supported only in VS COBOL II.
VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.
Under CICS Calls between VS COBOL II programs are supported.
Q:OS/VS COBOL和VS COBOL II有什么区别
A:OS/VS COBOL的PGM只能是24位地址的,VS COBOL II的PGM既能24位又能31位
报表writer只支持OS/VS COBOL
USAGE IS POINTER只支持VS COBOL II
REFERENCE(感觉翻成“引用”合适点)修改,比如:WS-VAR只支持VS COBOL II
只有COBOL II有EVALUATE语句
范围终止符只有COBOL II中才有
OS/VS COBOL是按照ANSI 74标准,VS COBOL II是按照ANSI 85标准
VS COBOL II程序之间允许CICS调用

Q58) What are the steps you go through while creating a COBOL program executable?
Q58) DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobol compiler, Link editor. If DB2
program, create plan by binding the DBRMs.
Q:建立一个COBOL可执行程序要通过哪些步骤
A:DB2预编译(如果内含SQL),CICS翻译器(如果是CICS PGM),COBOL编译器,连接编辑器,如果是DB2程序,要建立绑定DBRM的PLAN

Q59) Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
Q59) In non-CICS environment, it is possible. In CICS, this is not possible.
Q:能不能在VS COBOL II的PGM中调用OS VS COBOL的PGM?
A:在没有CICS的环境中,是可以的,在CICS环境中不行

Q60) What are the differences between COBOL and COBOL II?
A60) There are at least five differences:
COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces
new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and
addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER,
ISAM, Etc.), and It offers enhanced CICS support.
Q:COBOL和COBOL II什么区别
A:有五点不同,COBOL II支持结构变成(通过PERFORMS和一系列范围终止符);COBOL II引进了些新的特性(如EVALUATE,SET TO TRUE,CALL,BY CONTEXT,等等),COBOL II允许程序编址在16MB行上;COBOL II不支持一些旧的特性(如READY TRACE,REPORT-WRITER,ISAM,ETC),以及支持加强版CICS

Q61) What is an explicit scope terminator?
A61) A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.
Q:什么是范围终止符
A:一个范围终止符和其之前的动词配套使用,如,IF和END-IF,以至于前置动词和终止符一起作用。COBOL II其他普通的词是READ,PERFORM,EVALUATE,SEARCH和STRING

Q62) What is an in line PERFORM? When would you use it? Anything else to say about it?
A62) The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.
Q:PERFORM行有什么作用?什么时候使用?简单介绍下它
A:PERFORM和END-PERFORM配套使用,所有COBOL II程序语句都在这两关键字之间。这和COBOL的PERFORM或者PERFORM THRU一段是一样的意思。在PERFORM的语句中只要没有内部GOTO就一直执行直到碰到EXIT。在行PERFORM语句中为了可读型不能超过一页的长度,他经常会引用到其他PERFORM段

Q63) What is the difference between NEXT SENTENCE and CONTINUE?
A63) NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II’s finer implementations). It’s safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.
Q:NEXT SENTENCE和CONTINUE有什么区别
A:(这在前面已经详细说明,这样仅就文字翻译)NEXT SENTENCE当碰到‘.’转移程序控制权给下句,CONTINUE碰到范围终止符就转移程序控制权给下句。所以用CONTINUE比用NEXT SENTENCE安全(即使忘记写‘.’也没有关系)。

Q64) What COBOL construct is the COBOL II EVALUATE meant to replace?
A64) EVALUATE can be used in place of the nested IF THEN ELSE statements.
Q:COBOL II中的EVALUATE相当于取代了COBOL中的什么结构
A:EVALUATE相当于取代了COBOL中的IF THEN ELSE的嵌套语句

Q65) What is the significance of ‘above the line’ and ‘below the line’?
A65) Before IBM introduced MVS/XA architecture in the 1980’s a program’s virtual storage was limited to 16 megs. Programs compiled with a 24 bit mode can only address 16 Mb of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be ‘above the 16 Mb line. (This ‘below the line’, ‘above the line’ imagery confuses most mainframe programmers, who tend to be a literal minded group.)
Q: ’above the line’和‘below the line’有什么意义
A:在IBM推出MVS/XA体系之前,80年代的程序虚拟存储都限制在16 megs.程序以24位的方式仅在一个16Mb的地址空间中被编译,就好象那些程序被保存在虚存中一样。使用COBOL II编码之后,以31位方式的编码能超过16位的界线。(也就是说COBOL II之前是“在此界线之下”的,COBOL II之后“在这接线之上”,这通常容易使一些主机程序员搞混)

Q66) What was removed from COBOL in the COBOL II implementation?
A66) Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.
Q:COBOL II从COBOL中舍弃了哪些
A:部分列表(指COBOL中有的,COBOL II中没有的部分语句):REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.

Q67) Explain call by context by comparing it to other calls.
A67) The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.
Q:通过比较和其他调用的区别解释下CONTEXT调用
A:传入CONTEXT调用的参数是能防止被其他程序调用修改的。普通的调用,别的程序能够修改

Q68) What is the linkage section?
A68) The linkage section is part of a called program that ‘links’ or maps to data items in the calling program’s working storage. It is the part of the called program where these share items are defined.
Q:LINKAGE SECTION是什么
A:“连接区”是一个被调用程序连接或者映射到调用程序工作单元的程序部分。被调用程序中一些共享项被定义在“连接区”中(想象下子程序,主程序是没有连接区的)

Q69) What is the difference between a subscript and an index in a table definition?
A69) A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program’s working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.
Q:在表的定义中,下表和索引有什么区别
A:(这也在前面的题目也解释过了,这里仅对文字作翻译。)下表是工作单元数据定义项,具有代表性的就是将一个常量移到一个PIC 999下标中,通过ADD TO 和SUBTRACT FROM来增减。索引是一个存在在程序工作单元之外的记录项。用SET设置一个索引的值,并用UP BY和DOWN BY设置步长来增减

Q70) If you were passing a table via linkage, which is preferable - a subscript or an index?
A70) Wake up - you haven’t been paying attention! It’s not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us who’ve made this mistake, appreciate the lesson more than others.
Q:如果通过连接传递一个表,使用哪个更优-下标或者索引?
A:注意!是不能通过连接传递索引的。索引并不是调用程序工作单元的一部分。这点经常搞错

Q71) Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc.
A71) An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntax’s: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.
Q:解释下内部排序和外部排序的区别和内部排序的语法
A:外部排序不是COBOL,他是通过JCL和PGM=SORT的形式排序的。这种方式不引用代码却容易理解。内部排序用两中语法:1)USING,GIVING,这种方式比得上外边排序,不用额外的文件处理。2)INPUT PROCEDURE, OUTPUT PROCEDURE,这种方式适用用文件操作,并且在排序前后允许数据操作

Q72) What is the difference between comp and comp-3 usage? Explain other COBOL usage’s.
A72) Comp is a binary usage, while comp-3 indicates packed decimal. The other common usage’s are binary and display. Display is the default.
Q:COMP和COMP-3有什么区别?解释下COBOL中的USAGE语句
A:COMP用的是定点二进制,COMP-3用的是内部十进制(压缩)。其他的不同USAGE语句就是二进制和DISPLAY。DISPLAY是默认情况。

Q73) When is a scope terminator mandatory?
A73) Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it’s recommended coding practice to always make scope terminators explicit.
Q:什么时候范围终止符强制执行
A:范围终止符在行内PERFORM和EVALUATE语句中强制执行。为了程序的可读性,编码规范都建议写上这两个终止符。(也就是说PERFORM和EVALUATE就算没有END-PERFORM和END-EVALUATE也会强制终止,但是为了可读性还是建议把END-PERFORM和END-EVALUATE写上)

Q74) In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?
A74) In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.
Q:COBOL的PERFORM中什么时候测试CONDITION,在执行PERFORM之前还是之后
A:在COBOL II中有个WITH TEST BEFORE 或者WITH TEST AFTER的选项子句能够指定在执行前还是后测试CONDITION,默认情况是在执行前测试

Q75) In an EVALUTE statement is the order of the WHEN clauses significant?
A75) Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.
Q:在EVALUATE语句中,WHEN子句的顺序是否有意义
A:当然有意义。EXALUATION通过WHEN子句从头到尾的执行顺序会决定结果。

Q76) What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default.
A76) INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.
Q:INITIALIZE默认是值是什么?替代默认值的关键字是什么
A:默认情况下INITIALIZE将空格移到字符区,将零移到数字区。REPLACING作为替代默认值的关键保留字

Q77) What is SET TO TRUE all about, anyway?
A77) In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II’s better specifications.)
Q:总之,说明关于SET TO TRUE的一切
A:在COBOL II中88层是通过将关联值移到关联数据项中来设置的(这点改变并不是COBOL II好的地方)。(也就是说88层是通过其关联的数据项也就是上一层的,比如‘Y’或者‘N’来决定TRUE或者FALSE)

Q78) What is LENGTH in COBOL II?
A78) LENGTH acts like a special register to tell the length of a group or elementary item.
Q:COBOL II中LENGTH是什么
A:LENGTH就象个专用寄存器来显示GROUP的长度或者基本项的长度

Q79) What is the difference between a binary search and a sequential search? What are the pertinent COBOL
commands?
A79) In a binary search the table element key values must be in ascending or descending sequence. The table is ‘halved’ to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.
Q:二叉搜索和顺序搜索有什么区别?相关的COBOL命令是什么
A:(关于二叉搜索之前已经详细讲过了)要用二叉搜索一个表,那该表一定要按照这个KEY值是排序的(递增或者递减)。该表被一次次得平分直到找到目标元素。顺序搜索是从表头查到尾,所以这些元素是不是按照什么顺序排的无所谓。二分搜索对于大数据量的表查找速度很快,顺序搜索适合数据量小的表。SEARCH ALL用在二叉搜索中,SEARCH用在顺序查找中

Q80) What is the point of the REPLACING option of a copy statement?
A80) REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.
Q:REPLACING项复制语句的要点是什么
A:REPLACING用对指定的数据做不止一次的相同拷贝,也就是说在同一段程序中要多次拷贝相同的数据的时候用REPLACING

Q81) What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program i.e. a
program which is not calling any other program.
A81) The program will go in an infinite loop.
Q:在COBOL中如果你用GO BACK代替STOP RUN会发生什么,该程序没有调用别的程序
A:当然是会无限循环下去

Q82) How can I tell if a module is being called DYNAMICALLY or STATICALLY?
A82) 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
Q:怎么知道一个模块是动态的还是静态的
A:只能通过看连接编辑器(IEWL)或者LOAD模块本身(编译生成的模块)的输出来看是DYNAMICALLY还是STATICALLY的。如果一个模块被叫成动态模块,那么他不会出现在主模块中,如果是静态模块,那么会出现在LOAD模块中。调用一个工作单元区的变量,包括一个程序名,并不是动态调用。这种被工作单元区内容中的变量以调用模块名字的的形式的调用是固定调用。

Q83) What is the difference between a DYNAMIC and STATIC call in COBOL.
A83) To correct an earlier answer: All called modules cannot run stand alone 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 u 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.
Q:COBOL中动态动用和静态调用有什么区别
A:所有被调用的模块都不能单独跑除非这些模块要求程序通过连接区传递变量给他们。动态调用的模块就是那些在连接编辑时(LEWL)没有被调用程序限定的模块,这些模块在程序库(JOBLIB,STEPLIB)中被加载以连接JOB。要动态调用一个模块,DYNAM的编译器选项要被选中,另外,连接编辑器不能是可执行的,因为他会要你处理所有的模块。一个静态调用在连接编辑时被调用程序限制,所以变成了可执行模块的一部分。

Q84) How may divisions are there in JCL-COBOL?
A84) Four
Q:JCL-COBOL中有几个区
A:四个区

Q85) What is the purpose of Identification Division?
A85) Documentation.
Q:写标识区是什么目的
A:标识一些作者等信息,便于文档管理

Q86) What is the difference between PIC 9.99 and 9v99?
A86) 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.
Q:PIC 9.99和9V99有什么区别
A:PIC 9.99是一块占用了4个位置的区域,因为包括了一个小数点,但是9V99只占用3个位置,因为V不占位

Q87) what is Pic 9v99 Indicates?
A87) 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.
Q:PIC 9V99指什么
A:PIC 9V99指一段含有一个不占位置的小数点的占三个位置的数值区域。小数点位置在第一个位置之后,V表示一个隐含的小数点。

Q88) What guidelines should be followed to write a structured Cobol prg’m?
A88)
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.
Q:按照什么原则/方针去写一段结构化的COBOL程序(也就是程序规范)
A:1)用‘EVALUATE’语句去对应不用的情况
2)嵌套的时候不要忘记写范围终止符
3)用PERFORM语句来写要执行的语句(也就是说把要执行的语句写成一段然后用行PERFORM语句去执行,不要光把要执行的语句罗列在主程序中)
4)用在使用PERFORM语句之前和之后都检测(我们现在常用的是检测文件状态)这种方式来写DO-WHILE结构(不要问我DO-WHILE结构是什么)

Q89) 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 ?
A89) 5 times only. it will not take the value 10 that is initialized in the loop.
Q: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.
这段程序中b-para被执行几次
A:只执行5次。在循环中并不会取这个10的值。
我的理解是:在第一次执行perform b-para ws-n times.的时候并没有通过move 10 to ws-n.修改ws-n的值,也就是说在该循环语句中取到的ws-n还是5,那就该执行(将10移到ws-n 5次),如果最后再跟一句c-para.perform b-para ws-n times.这样的话b-para就该执行10次了

Q90) What is the difference between SEARCH and SEARCH ALL? What is more efficient?
A90) SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a binary search, continually dividing the table in two halves until a match is found. SEARCH ALL is more efficient for tables larger than 70 items.
Q:SEARCH和SEARCH ALL有什么区别?哪个更高效
A:SEARCH是顺序查找,从头到尾。SEARCH是二叉搜索。超过70个数据项的时候SEARCH ALL效率更高

Q91) What are some examples of command terminators?
A91) END-IF, END-EVALUATE
Q:给出命令终止符的例子
A:END-IF,END-EVALUATE

Q92) What care has to be taken to force program to execute above 16 Meg line?
A92) Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE(MAX). BUFSIZE can be 2K, efficient enough.
Q:强制程序执行超过16Meg行的时候应该注意什么
A:确认连接选项AMODE=31和RMODE=ANY.

Q93) How do you submit JCL via a Cobol program?
A93) Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this out.
Q:怎么通过COBOL提交一个JCL
A:将//dd1 DD sysout=(*, intrdr)写在JCL中

Q94) How to execute a set of JCL statements from a COBOL program
A94) Using EXEC CICS SPOOL WRITE(var-name) END-EXEC command. var-name is a COBOL host structure containing JCL statements.
Q:怎么在一个COBOL程序中执行一段JCL语句
A:使用EXEC CICS SPOOL WRITE(变量) END-EXEC命令。变量名是一个包括一段JCL语句的COBOL结构

Q95) Give some advantages of REDEFINES clause.
A95)
1. You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory
location.
2. By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself.
3. We can REDEFINE a Single Variable into so many sub variables. (This facility is very useful in solving Y2000
Problem.)
Q:说明REDEFINES子句的优点
A:1:你能用另一个PICTURE(另一种类型)重定义之前的一种类型,并且以相同的起点
2:在工作单元区中能通过REDEFINES初始化变量
3:能够通过重定义一个变量而重定义很多子变量。(这个来解决Y2000问题很方便)
PS:在多维表的元素初始化中也用到REDEFINE,不过这和第3点作用类似

Q96) What is the difference between static call & Dynamic call
A96) In the case of Static call, the called program is a stand-alone program, it is an executable program. During run time we can call it in our called program. As about Dynamic call, the called program is not an executable program it can executed through the called program
Q:静态调用和动态调用有什么区别
A:在静态调用的情况下,被调用的程序是单独的一段程序,他是一段可执行的程序。在跑程序的时候能够调用它。而关于动态调用,被调用程序并不是一段可执行程序,但能通过调用程序而执行

Q97) What do you feel makes a good program?
A97) A program that follows a top down approach. It is also one that other programmers or users can follow logically and is easy to read and understand.
Q:你认为怎么才能写相互好的程序
A:一段好的程序要遵循从上到下步骤。这也能使程序员和用户能够根据逻辑容易得读懂程序

Q98) How do you code Cobol to access a parameter that has been defined in JCL? And do you code the PARM
parameter on the EXEC line in JCL?
A98)
1) using JCL with sysin. //sysin dd *here u code the parameters(value) to pass in to cobol program /* and in program
you use accept variable name(one accept will read one row)/.another way.
in jcl using parm statement ex: in exec statement parm=’john’,'david’ in cobol pgm u have to code linkage section in that for first value you code length variable and variable name say, abc pic x(4).it will take john inside to read next value u have to code another variable in the same way above mentioned.
Q:怎么编写一个COBOL去访问一个JCL定义的参数?你会在JCL的EXEC行上写PARM参数吗?
A:1)用JCL的SYSIN。//sysin dd *这里你写参数*/ 这样就能把参数传给COBOL
2)在JCL中用PARM语句,比如:在EXEC行写parm==’john’,'david’,那么你就必须在PGM的连接区中为第一个值写变量长度和变量名,如:abc pic x(4),就会在这个变量前加上之前的PARM(’john’,'david’),你需要用以上的方法定义其他参数

Q99) Why do we code S9(4) comp. In spite of knowing comp-3 will occupy less space.
A99) Here s9(4)comp is small integer ,so two words equal to 1 byte so totally it will occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
Q:既然已经知道COMP-3会占用较少的空间,为什么还要编码S9(4)COMP
A:这里S9(4)COMP是个小整数,所以2个数值相当于一个字节,所以一共占用2字节。如果是S9(4)COMP-3的情况就是1个数值占半个字节。4个数值占用2个字节,符号占半个字节,这么算一共是2个半字节,但是系统存储的最小单位是字节,所以一共占3个字节
虽然COMP-3占用少的空间(这里的较少是相对于DISPLAY型说的),但是COMP占用少的时间,效率更高。

Q100) The maximum number of dimensions that an array can have in COBOL-85 is ———– ?
A100) SEVEN in COBOL - 85 and THREE in COBOL – 84
Q:在COBOL-85中一个数组最多能是几维的
A:COBOL-85最多是七维,COBOL-84最多是三维

Q101) How do you declare a host variable (in COBOL) for an attribute named Emp-Name of type VARCHAR(25) ?
A101)
01 EMP-GRP.
49 E-LEN PIC S9(4) COMP.
49 E-NAME PIC X(25).
Q:在COBOL中怎么申明一个带有类型为25位字符型属性的变量
A:答案见上

Q102) What is Comm?
A102) COMM - HALF WORD BINARY
Q:什么是COMM

Q103) Differentiate COBOL and COBOL-II. (Most of our programs are written in COBOLII, so, it is good to know,
how, this is different from COBOL)
A103) The following features are available with VS COBOL II:
1. MVS/XA and MVS/ESA support The compiler and the object programs it produces can be run in either
24- or 31-bit addressing mode.
2. VM/XA and VM/ESA support The compiler and the object programs it produces can be run in either
24- or 31-bit addressing mode.
3. VSE/ESA support The compiler and the object programs it produces can be run under VSE/ESA.
Q:请区分COBOL和COBOL II(大部分程序是用COBOL II写的,所以比较好理解,但是这和COBOL是不同的)
A:以下是COBOL与VS COBOL II的不用点
支持MVS/XA和MVS/ESA。COBOL提供的编译器和OBJECT程序能够在24或者31位的寻址方式下执行
支持VM/XA和VM/ESA。其提供的编译器和OBJECT程序能够在24或者31位的寻址方式下执行
支持VSE/ESA。其提供的编译器和OBJECT程序能够在VSE/ESA环境下执行

Q104) What is PERFORM ? What is VARYING ? (More details about these clauses)
A104) The PERFORM statement is a PROCEDURE DIVISION statement which transfers control to one or more specified procedures and controls as specified the number of times the procedures are executed. After execution of the specified procedures is completed (i.e., for the appropriate number of times or until some specified condition is met), control is transferred to the next executable statement following the PERFORM statement. There are 5 types of PERFORM statements:

a) Basic PERFORM
b) PERFORM TIMES
c) PERFORM UNTIL
d) PERFORM VARYING
e) IN-LINE PERFORM
Q:PERFORM是什么?VARYING是什么?(详细介绍下这些子句)
A:PERFORM语句是过程部的语句,它能将程序控制权交给一段指定的程序,并按照指定的次数执行(也就是说执行一段程序,PERFORM XXX N TIMES)等到这段程序执行完之后(比如,指定要执行的次数执行到了或者UNTIL后的判断逻辑为真),那么程序控制权就会转到下一条执行语句(也就是执行下一条语句,紧跟该PERFORM的),有5种PERFORM语句:
基本 PERFORM
PERFORM XXX N TIMES
PERFORM XXX UNTIL YYY
PERFORM XXX VARYING
内嵌PERFORM
Q105) How many sections are there in data division?.
A105) SIX SECTIONS 1.FILE SECTION 2.WORKING-STORAGE SECTION 3. LOCAL-STORAGE SECTION 4.SCREEN SECTION 5.REPORT SECTION 6. LINKAGE SECTION
Q:数据部中有几个区
A:6个区 1,文件区;2,工作单元区;3,本地存储区;4,屏幕显示区;5,报告区;6,连接区

Q106) What is Redefines clause?
A106) Redefines clause is used to allow the same storage allocation to be referenced by different data names .
Q:REDEFINES子句是什么
A:当想用不用的数据名写在相同的存储分配地址的时候用REDEFINES
Q107) How many bytes does a s9(4)comp-3 field occupy?
A107) 3Bytes (formula : n/2 + 1))
Q:S9(4)COMP-3占多少字节
A:3个字节

Q108) What is the different between index and subscript?
A108) Subscript refers to the array of occurrence , where as Index represents an occurrence of a table element. An index can only modified using perform, search & set. Need to have an index for a table in order to use SEARCH and SEARCH All.
Q:索引和下标的区别是什么
A:下标引用数组的出现位置,索引指向表元素出现的地址。索引只能通过PERFORM,SEARCH和SET修改。要使用SERACH和SEARCH ALL就要为表建个索引

Q109) What is the difference between Structured COBOL Programming and Object Oriented COBOL
programming?
A109) Structured programming is a Logical way of programming, you divide the functionalities into modules and code logically. OOP is a Natural way of programming; you identify the objects first, and then write functions, procedures around the objects. Sorry, this may not be an adequate answer, but they are two different programming paradigms, which is difficult to put in a sentence or two.
Q:结构化的COBOL编程和面向对象的编程有什么区别
A:结构化的编程是一种逻辑的方法,将程序实现的功能分成各个模块然后根据逻辑顺序对其编码。面向对象的编程就是一种“自然”的编程方法,先定义一个对象,然后围绕着该对象写函数,过程。这不一定是完整的回答,但是这是两种不同的编程方式,很难用一两句话来说清楚

Q110) What divisions, sections and paragraphs are mandatory for a COBOL program?
A110) IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a compilation error free COBOL
program.
Q:那些部,区,段是一个COBOL程序所必须的
A:标识部和PROGRAM-ID段是正确编译一个COBOL程序所必须的

Q111) Can JUSTIFIED be used for all the data types?
A111) No, it can be used only with alphabetic and alphanumeric data types.
Q:JUSTIFIED能用于所有的数据类型吗
A:不能,只能用于字母和字符类型

Q112) What happens when we move a comp-3 field to an edited (say z (9). ZZ-)
A112) the editing characters r to be used with data items with usage clause as display which is the default. When u tries displaying a data item with usage as computational it does not give the desired display format because the data item is stored as packed decimal. So if u want this particular data item to be edited u have to move it into a data item whose usage is display and then have that particular data item edited in the format desired.
Q:把一段COMP-3区域移到编辑字符(Z(9).ZZ-),数据项怎么变化
A:使用编辑字符是用USAGE子句,默认情况下是DISPLAY。当你想用计算型的格式打印这条数据项的时候它没没有按照你想要的格式打印。因为这数据项是按照外部十进制(DISPLAY型)存储的。所以当你想编辑这种特殊的数据项时你就把它移到一个指定为DISPLAY型的数据项中,然后按照指定的格式(这里的Z(9).ZZ-)编辑

Q113) What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program ?
A113) Both give the same results when a program is not calling any other program. GO BACK will give the control to the system even though it is a single program.
Q:在单独的一个COBOL程序中(这个程序不调用别的程序)将STOP RUN换成GO BACK会怎么样
A:当没有调用别的程序的时候GO BACK和STOP RUN都会给出相同的结果。当是单独程序的时候GO BACK会将程序控制权范围给系统

Q114) what is the difference between external and global variables?
A114) Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.
Q:外部变量和全局变量有什么区别
A:全程变量只能被同一个批处理程序访问,但是只要是同一个程序库(LIB)中任何批处理程序都可以引用外部变量

Q115) 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 so how do you do your checking for breaks and how do you do add to each level?
A115) 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 record but add to the higher level only on a break.
Q:首先和最高层做比较,因为最高层有断点,要追加到最低层的各个记录,加到高层只要加在断点上就行了

Q116) What is difference between COBOL and VS COBOL II?.
A116) In using COBOL on PC we have only flat files and the programs can access only limited storage, whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB depending on the addressing and can use VSAM
files to make I/O operations faster.
Q:COBOL和COBOL II有什么区别
A:用COBOL的话在PC上只有平面文件(不象VSAM那样的存贮方式)以及程序只能访问有限的存贮量,而在COBOL II上使用VSAM能是程序的访问存贮两提高到16MB到2GB,也使得I/O操作更快了

Q117) Why occurs can not be used in 01 level ?
A117) Because, Occurs clause is there to repeat fields with same format, not the records.
Q:为什么不能在01层使用OCCURS子句
A:因为01层是一整条记录,而OCCURS是按照相同的格式复制记录中的区域。

Q118) What is report-item?
A118) A Report-Item Is A Field To Be Printed That Contains Edit Symbols

Q119) Difference between next and continue clause
A119) The difference between the next and continue verb is that in the continue verb it is used for a situation where there in no EOF condition that is the records are to be accessed again and again in an file, whereas in the next verb the indexed file is accessed sequentially, read next record command is used.
Q:NEXT和CONTINUE子句
A:(之前有过详细的解释)CONTINUE

Q120) What is the Importance of GLOBAL clause According to new standards of COBOL
A120) 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.
Q:对于新标准的COBOL GLOBAL子句有什么重要性
A:任何数据名,文件名,记录名,状态名或者索引被定义在程序包含区内都能被直接或者间接得引用,更别说这些数据被申明成全局形式了。GLOBAL子句的形式是:
“01 DATA-1 PIC 9(5) IS GLOBAL”

Q121) What is the Purpose of POINTER Phrase in STRING command
A121) The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
Q:STRING命令中POINTER语句的作用是什么
A:POINTER句子是为了在接受区中指定最左边的位置,第一个被传进的字符会被保存在那个位置上

Q122) How do we get current date from system with century?
A122) By using Intrinsic function, FUNCTION CURRENT-DATE
Q:怎么从系统中获取现在时期和时间
A:使用固有函数FUNCTION CURRENT-DATE

Q123) What is the maximum length of a field you can define using COMP-3?
A123) 10 Bytes (S9(18) COMP-3).
Q:使用COMP-3,区域最大长度是多少
A:COMP-3存数字最多能存18个也就是9(18)(这个最大数字书上有说明),算上符号所以是10个 字节(最小存储单元是字节,所以不要问为什么不是9.5个字节)。

Q124) Why do we code s9 (4) comp? In spite of knowing comp-3 will occupy less space?
A124) Here s9(4)comp is small integer, so two words equal to 1 byte so totally it will occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
Q:尽管知道COMP-3更省空间,为什么还要用S(9)COMP?
A:该题目题目连答案与99题目一模一样。

Q125) What is the LINKAGE SECTION used for?
A125) The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program.
Q:LINKAGE SECTION有什么用
A:LINKAGE SECTION是用来将数据从一个程序传到另一个程序或者从一个过程(PROCEDURE)传到一个程序

Q126) Describe the difference between subscripting and indexing ?
A126) Indexing uses binary displacement. Subscripts use the value of the occurrence.
Q:解释下标和索引的区别
A:索引通过元素的相对地址来找到元素。下标是通过元素出现位置的值来找到该元素

1. What R 2 of the common forms of the EVALUATE STATEMENT ?
2. What does the initialize statement do ?
3. What is the reference modification.
4. Name some of the examples of COBOl 11?
5. What are VS COBOL 11 special features?
6. What are options have been removed in COBOL 11?
7. What is the file organization clause ?
8. What is a subscript ?
9. What is an index for tables?
10. What are the two search techniques ?
11. What is an in-line perform ?
12. What is CALL statement in COBOL?
13. When can the USING phrase be included in the call statement ?
14. In EBCDIC, how would the number 1234 be stored?
15. How would the number +1234 be stored if a PIC clause of PICTUREs9(4) comp-3 were used?
16. What is Alternate Index ? How is it different from regular index ?

 

原创粉丝点击