COBOL面试1—30题答案

更新时间:2023-05-19 06:05:12 阅读: 评论:0

COBOL面试1—30题答案
A1) IDENTIFICA TION DIVISION, ENVIRONMENT DIVISION, DA TA DIVISION, PROCEDURE DIVISION.
Q:列举COBOL的DEVISION
A:标识部,环境部,数据部,过程部
A2) Alpha-numeric (X), alphabetic (A) and numeric (9).
Q:COBOL有哪些可用的数据类型
星际之旅A:字符型(这里指的是包含字母和数字),字母型,数字型
A3) Alphabetic, Alphanumeric fields & alphanumeric edited items are t to SPACES. Numeric, Numeric edited items t to ZERO. FILLER , OCCURS DEPENDING ON items left untouched. Q:INITIALIZE这个词做了些什么
A:将字母,字符,数字区域都置成空格(置空),将数字区置0,FILLER和OCCURS DEPENDING ON项不处理
A4) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themlves.
Q:77层有什么作用
A:基本层数据项,不能用做细分别的层,也不能被细分
A5) For condition names.
Q:88层有什么作用
A:条件逻辑层
A6) For RENAMES clau.
Q:66层有什么作用
A:重命名层
A7) IS NUMERIC can be ud 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还有+和-
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:如上.
A9) No.
Q:OCCURS 子句能用在第一层吗
A:不能
hauling
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
u SEARCH, SEARCH ALL.
Q:索引和下标有什么区别
A:下标可以指定数组中任意中位置的元素(只要知道其下标),下标只能是数字型常量或者数字型变量(但是不能在指定的时候修改,如:A(K+1)这样是不行的,要修改的话要在指定的外部改,如:ADD 1 TO K,而索引的话是从表头/数组头开始检索(以BY N的指定检索规律往后滚)
再者,索引只能通过PERFORM, SEARCH 和SET来修改,如果要在一个表中使用SEARCH, SEARCH ALL,那这个表就要有索引(因为SEARCH, SEARCH ALL的参数中指定索引,所以即使其有很多限制还是得用它)
A11) SEARCH - is a rial arch.诚信的诗句
SEARCH ALL - is a binary arch & the table must be sorted ( ASCENDING/DESCENDING KEY clau to be ud & 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
A12) It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the arch to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clau. (Y ou must load the table in the specified order).
Q:为了使用SEARCH ALL,存贮顺序是怎么样的
A:他必须是递增或者是递减的,默认地政。如果你想在一个递减顺序存贮的表/数组使用搜索的话,那么当定义表/数组的时候你应该加一个DESCENDING KEY子句(这之前表要已经按指定的顺序排序了)
A13) Search on a sorted array. Compare the item to be arched with the item at the center. If it matches, fine el repeat the process with the left half or the right half depending on where the item lies.
Q:什么是2叉查找
A:将你要找的目标项与数组的正中项比较,找到就结束搜索,没找到则继续如此循环(比较下一个中值),取哪一半取决于目标值大于中值还是小于中值给自己一个目标
PS:联想2叉树的查找规律就很好理解,因为所谓的“表“本身也就是数组
A14) Must u compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
Q:我的程序有个数组定义了10项。因为有个BUG,我发现即使访问第11项,程序也不异常终止。那是出了什么问题
A:必须使用编译器的一个选项SSRANGE,如果你想检查数组的超界问题。默认是NOSSRANGE
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.
Q:怎么在一个COBOL程序中排序?给出排序文件的定义,排序语法和意思
A:同上
A16) U the SORTWK01, SORTWK02,….. dd names in the step. Number of sort datats depends on the volume of data being sorted, but a minimum of 3 is required.
Q:怎么在JCL中定义一个排序文件来跑这个COBOL程序
A:用SORTWK01, SORTWK02,…..作为DA TA SET NAME。用多少取决于你要排序的数量,但是至少3个。
A17) Performing a SECTION will cau all the paragraphs that are part of the ction, to be performed. Performing a PARAGRAPH will cau only that paragraph to be performed.
Q:执行一个区和一个段有什么区别
A:简单来说的话就是区的概念比段大,执行一个区就要执行其内部所有段,执行段的话只执行该段。
A18) Evaluate is like a ca statement and can be ud to replace nested Ifs. The difference between EV ALUA TE and ca is that no ‘break’ is required for EV ALUA control comes out of the EV ALUA TE as soon as one match is made.
Q:EV ALUATE语句有什么作用
A:EV ALUA TE就象个CASE语句(多重开关语句,学过C的总知道吧),不同点在于EV ALUA TE不需要BREAK,一旦匹配就跳出EV ALUA TE语句了
A19) EV ALUA TE TRUE
WHEN condition  statement-1
Statement-2
WHEN condition statement-3
Statement-4
WHEN other other statements
END-EV ALUA TE.
Q: EV ALUATE语句有哪些类型?
A20) After the execution of one of the when claus, the control is automatically pasd on to the next ntence after the EV ALUA TE statement. There is no need of any extra code.
Q:怎么跳出一条EV ALUATE语句?
A:象18题目说的那样,一旦匹配了某一个“WHEN“语句就自动跳出了,不需要什么额
外的代码来跳出
A21) Yes.
Q:在一个EV ALUATE语句的某个WHEN分支中能否再插入复杂的情况(也就是嵌套)A:当然可以,当多个参数作为控制变量的时候1个WHEN内部可以嵌套更多的情况
A22) Scope terminator is ud to mark the end of a EV ALUA TE, END-EV ALUA TE; IF, END-IF.
Q:什么是结束终止符?
A:结束终止符是搭配一些范围指令的,也就是标识一些范围指令的结束。如:EV ALUA TE, END-EV ALUA TE; IF, END-IF 如果没有该结束符,该条语句将终止不了
A23) PERFORM … …END-PERFORM.
Q:怎么使用内嵌的PERFORM?
A:PERFORM ……END-PERFORM.
所谓内嵌也就是PERFORM被嵌在某些比如循环语句中担当执行主体,同时通过UNTIL来指定结束判定
A24) When the body of the perform will not be ud in other paragraphs. If the body of the perform is a generic type of code(ud from various other places in the program), it would be better to put the code in a parate Para and u PERFORM Para name rather than in-line perform. Q:什么时候使用内嵌式PERFORM?
A:当该段PERFORM的内容不被其他段用到,只在某些局部代码中(当然PERFORM的主体所用到
的参数也都是局部的,例如循环)使用,如果PERFORM主体的代码是一般的(用到了别的程序段的变量),还是使用PERFORM Para name这样的形式比较好(也就是相对与内于PERFORM的外部PERFORM)。
A25) continue:the control goes to the next ntence in the paragraph. But, Next Sentence would take the control to the ntence after it finds a full stop (.). Run the ntence after the first full stop.
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)来判断下一句的.
A26) Does nothing ! If ud, must be the only ntence within a paragraph.
Q:EXIT语句有什么作用
A:什么都不做,如果用到的话,肯定是作为一段的唯一的一句话,注意:这里不是子程序中用的EXIT PROGRAME
A27) Yes. Redefines just caus 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)1 Yes.
Q:能不能把X(200)的区域重定义成X(100)
A:可以,原因同上
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) In the most significant bit. Bit is ON if -ve, OFF if +ve.
Q:COMP区怎么存储符号
A:COMP采用定点二进制的方式存储数据,也就是将一个十进制的数值转化成二进制再进行存储,因为机器存储的形式也是二进制,所以定点二进制的读取是最快速的,因为COMP 型的数据是用做计算(也就是说不用再转化成十进制打印),使用定点二进制将会非常高效。这样的存储方式符号保存
在最高有效位,如:10=(00001010)₂,-10=(00011010)₂
Q35) COMP is a binary storage format while COMP-3 is packed decimal format.
感谢信任Q:COMP和COMP-3什么区别

本文发布于:2023-05-19 06:05:12,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/690959.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:数组   语句   使用   排序   指定
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图