77家的会客2010

COBOL经典面试题库(65~126)
Weather:小雨,天气很阴

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:索引通过元素的相对地址来找到元素。下标是通过元素出现位置的值来找到该元素

[COBOL经典面试题库(65~126)]的回复

Post a Comment~