COBOL經典面試題庫(中英文版)

 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 ?

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章