COBOL Programming InterviewQuestions, Answers and Explanations
By Terry Sanchez-Clark
ITCOOKBOOK
COBOL Programming InterviewQuestions and Answers Book
978-1-60332-238-6
SmashwordsEdition
Compiled by TerrySanchez-Clark
ITCOOKBOOK
Edited by Emilee NewmanBowles
Copyright 2007 Equity Pressand IT COOKBOOK all rights reserved. No part of this publicationmay be reproduced, stored in a retrieval system, or transmitted inany form or by any means (electronic, mechanical, photocopying,recording or otherwise) without either the prior written permissionof the publisher or a license permitting restricted copying in theUnited States or abroad.
The scanning, uploading anddistribution of this book via the internet or via any other meanswith the permission of the publisher is illegal and punishable bylaw. Please purchase only authorized electronic editions, and donot participate in or encourage piracy of copyrightedmaterials.
The programs in this bookhave been included for instructional value only. They have beentested with care but are not guaranteed for any particular purpose.The publisher does not offer any warranties or representations notdoes it accept any liabilities with respect to theprograms.
Trademarks: All trademarksare the property of their respective owners. Equity Press is notassociated with any product or vendor mentioned in thisbook.
Please visit our websiteat www.itcookbook.com
Table ofContents
Many people might questionthe need - at this late date of 2007 - for an interview questionsbook on the COBOL programming language. That is to say, many peoplewould wonder if there are any jobs out there for COBOL programmers.Practitioners know, however, that there is a vibrant job market forthese skills. As more of the baby-boomer generation retire fromactive employment, who will fill these much needed positions? Smartprogrammers who want to make a good living at theirtrade.
This book published withyou, the Information Technology job seeker in mind the contractoror employee who knows that all you need is a few good books to getthe learning started, and eventually, the job done. So here is theCOBOL Interview Questions guide. I hope it will show you what youneed to know, and what you can safely ignore. This book will helpguide your learning and help you land your next COBOL programmingassignment. Good Luck!
Jim Stewart
Publisher
Equity Press
How many sections are therein Data Division?
A: It has six sections:
1. FILE SECTION
2. WORKING-STORAGESECTION
3. LOCAL-STORAGESECTION
4. SCREENSECTION
5. REPORTSECTION
6. LINKAGESECTION
In COBOL II, there are only4 sections:
1. FILE SECTION
2. WORKING-STORAGESECTION
3. LOCAL-STORAGESECTION
4. LINKAGESECTION
How can I tell if a moduleis being called dynamically or statically?
A: The only way is to look at the output of thelinkage editor (IEWL) or the load module itself. If the module isbeing called DYNAMICALLY, then it will not exist in the mainmodule. If it is being called STATICALLY, then it will be seen inthe load module. Calling a working storage variable, containing aprogram name, does not make a DYNAMIC call. This type of calling isknown as IMPLICITE calling as the name of the module is implied bythe contents of the working storage variable. Calling a programname literal (CALL).
What are the advantages ofVS COBOL II over OS/VS COBOL?
A: The working storage and linkage section limit hasbeen increased. They have 128 megabytes as supposed to 1 megabytein OS/VS COBOL. In using COBOL on PC we have only flat files andthe programs can access only limited storage. Whereas in VS COBOLII on M/F, the programs can access up to 16MB or 2GB depending onthe addressing and can use VSAM files to make I/O operationsfaster.
What are the steps increating a COBOL program executable?
A: DB2 pre-compiler (if embedded SQL is used), CICStranslator (if CICS program), COBOL compiler, Link editor. If DB2program, create plan by binding the DBRMs.
What are the minimumrequirements to compile a program without errors?
Is compute w=u a validstatement?
When will you prefercompute statement over the move statement in the aboveexample?
A: Look into the Identification Division. Go to >Program-ID > Program-name.
Compute w=u is a validstatement. It is equivalent to move u to w.
When significant left-orderdigits would be lost in execution, the COMPUTE statement can detectthe condition and allow you to handle it. The MOVE statementcarries out the assignment with destructive truncation. Therefore,if the size error needs to be detected, COMPUTE will be preferredover MOVE. The ON SIZE ERROR phrase of COMPUTE statement, compilergenerates code to detect size-overflow.
What is the differencebetween a DYNAMIC and STATIC call in COBOL?
A: All called modules cannot run standalone if theyrequire program variables passed to them via the LINKAGE section.Dynamically called modules are those that are not bound with thecalling program at link edit time (IEWL for IBM) and so are loadedfrom the program library (joblib or steplib) associated with thejob. For dynamic calling of a module the DYNAM compiler option mustbe chosen. Else the linkage editor will not generate an executableas it will expect null address resolution of all calledmodules.
A statically called moduleis one that is bound with the calling module at link edit, andtherefore becomes part of the executable load module.
How will you associate yourfiles with external data sets where they physicallyreside?
A: Using SELECT clause, the files can be associatedwith external data sets. The SELECT clause is defined in theFILE-CONTROL paragraph of Input-Output Section that is codedEnvironment Division. The File structure is defined by FD entryunder File-Section of Data Division for the OS.
How will you define yourfile to the operating system?
A: Associate the file with the external data setusing SELECT clause of INPUT-OUTPUT SECTION WHICH.
INPUT-OUTPUT SECTIONappears inside the ENVIRONMENT DIVISION.
Define your file structurein the FILE SECTION of DATA DIVISION.
What are the uses ofDeclaratives in COBOL?
A: Declaratives provide special sections that areexecuted when an exceptional condition occurs. They must be groupedtogether and coded at the beginning of procedure division, and theentire procedure division must be divided into sections.
The Declaratives start witha USE statement. The entire group of declaratives is preceded byDECLARATIVES and followed by END DECLARATIVES in area A.
The three types ofdeclaratives are:
1. Exception (when erroroccurs during file handling).
2. Debugging (to debuglines with 'D' coded in w-s section).
3. Label (for EOF orbeginning...) declaratives.
What is the differencebetween PIC 9.99 and 9v99?
A: PIC 9.99 is a four-position field that actuallycontains a decimal point while PIC 9v99 is three-position numericfield with implied or assumed decimal position.
When is the COMMONattribute used?
A: COMMON attribute is used with nested COBOLprograms. If it is not specified, other nested programs cannotaccess the program.
PROGRAM-ID Pgmname isCOMMON PROGRAM.
What is Picture 9v99Indicates?
A: Picture 9v99 is a three position numeric fieldwith an implied or assumed decimal point after the first position.The v means an implied decimal point.
What is a LOCAL-STORAGESECTION?
A: Local-Storage is allocated each time the programis called and is de-allocated when the program returns in an EXITPROGRAM, GOBACK, or STOP RUN. Any data items with a VALUE clauseare initialized to the appropriate value each time the program iscalled. The value in the data items is lost when the programreturns. It is defined in the DATA DIVISION after WORKING-STORAGESECTION.
Next page