COBOL面试问题大全.docx
- 文档编号:12565617
- 上传时间:2023-04-20
- 格式:DOCX
- 页数:11
- 大小:19.48KB
COBOL面试问题大全.docx
《COBOL面试问题大全.docx》由会员分享,可在线阅读,更多相关《COBOL面试问题大全.docx(11页珍藏版)》请在冰豆网上搜索。
COBOL面试问题大全
COBOL面试问题大全
1.NamethedivisionsinaCOBOLprogram.
IDENTIFICATIONDIVISION,ENVIRONMENTDIVISION,DATADIVISION,PROCEDUREDIVISION.
1.WhatarethedifferentdatatypesavailableinCOBOL?
Alpha-numeric(X),alphabetic(A)andnumeric(9).
2.WhatdoestheINITIALIZEverbdo?
–
Alphabetic,Alphanumericfields&alphanumericediteditemsaresettoSPACES.
Numeric,NumericediteditemssettoZERO.
FILLER,OCCURSDEPENDINGONitemsleftuntouched.
3.Whatis77levelusedfor?
Elementarylevelitem.Cannotbesubdivisionsofotheritems(cannotbequalified),norcantheybesubdividedthemselves.
4.Whatis88levelusedfor?
Forconditionnames.
5.Whatislevel66usedfor?
ForRENAMESclause.
6.WhatdoestheISNUMERICclauseestablish?
ISNUMERICcanbeusedonalphanumericitems,signednumeric&packeddecimalitemsandusignednumeric&packeddecimalitems.ISNUMERICreturnsTRUEiftheitemonlyconsistsof0-9.However,iftheitembeingtestedisasigneditem,thenitmaycontain0-9,+and-.
7.WhatdoestheISNUMERICclauseestablish?
ISNUMERICcanbeusedonalphanumericitems,signednumeric&packeddecimalitemsandusignednumeric&packeddecimalitems.ISNUMERICreturnsTRUEiftheitemonlyconsistsof0-9.However,iftheitembeingtestedisasigneditem,thenitmaycontain0-9,+and-.
8.CantheOCCURSclausebeatthe01level?
No.
9.Whatisthedifferencebetweenindexandsubscript?
Subscriptreferstothearrayoccurrencewhileindexisthedisplacement(innoofbytes)fromthebeginningofthearray.AnindexcanonlybemodifiedusingPERFORM,SEARCH&SET.
NeedtohaveindexforatableinordertouseSEARCH,SEARCHALL.
10.WhatisthedifferencebetweenSEARCHandSEARCHALL?
SEARCH-isaserialsearch.
SEARCHALL-isabinarysearch&thetablemustbesorted(ASCENDING/DESCENDINGKEYclausetobeused&dataloadedinthisorder)beforeusingSEARCHALL
11.WhatshouldbethesortingorderforSEARCHALL?
ItcanbeeitherASCENDINGorDESCENDING.ASCENDINGisdefault.Ifyouwantthesearchtobedoneonanarraysortedindescendingorder,thenwhiledefiningthearray,youshouldgiveDESCENDINGKEYclause.(Youmustloadthetableinthespecifiedorder).
12.Whatisbinarysearch?
Searchonasortedarray.Comparetheitemtobesearchedwiththeitematthecenter.Ifitmatches,fineelserepeattheprocesswiththelefthalfortherighthalfdependingonwheretheitemlies.
13.Myprogramhasanarraydefinedtohave10items.Duetoabug,Ifindthateveniftheprogramaccessthe11thiteminthisarray,theprogramdoesnotabend.Whatiswrongwithit?
MustusecompileroptionSSRANGEifyouwantarrayboundschecking.DefaultisNOSSRANGE.
14.HowdoyousortinaCOBOLprogram?
Givesortfiledefinition,sortstatementsyntaxandmeaning.
Syntax:
SORTfile-1ONASCENDING/DESCENDINGKEYkey....
USINGfile-2
GIVINGfile-3.
USINGcanbesubstitutedbyINPUTPROCEDUREISpara-1THRUpara-2
GIVINGcanbesubstitutedbyOUTPUTPROCEDUREISpara-1THRUpara-2.
file-1isthesortworkfileandmustbedescribedusingSDentryinFILESECTION.
file-2istheinputfilefortheSORTandmustbedescribedusinganFDentryinFILESECTIONandSELECTclauseinFILECONTROL.
file-3istheoutfilefromtheSORTandmustbedescribedusinganFDentryinFILESECTIONandSELECTclauseinFILECONTROL.
file-1,file-2&file-3shouldnotbeopenedexplicitly.
INPUTPROCEDUREisexecutedbeforethesortandrecordsmustbeRELEASEdtothesortworkfilefromtheinputprocedure.
OUTPUTPROCEDUREisexecutedafterallrecordshavebeensorted.RecordsfromthesortworkfilemustbeRETURNedoneatatimetotheoutputprocedure.
15.HowdoyoudefineasortfileinJCLthatrunstheCOBOLprogram?
UsetheSORTWK01,SORTWK02,.....ddnamesinthestep.Numberofsortdatasetsdependsonthevolumeofdatabeingsorted,butaminimumof3isrequired.
16.WhatarethetwowaysofdoingsortinginaCOBOLprogram?
Givetheformats.
Seequestion16.
17.GivetheformatofUSINGandGIVINGinSORTstatement.Whataretherestrictionswithit?
Seequestion16.Restrictions-Cannotmassagerecords,canotselectrecordstobesorted.
18.WhatisthedifferencebetweenperformingaSECTIONandaPARAGRAPH?
PerformingaSECTIONwillcausealltheparagraphsthatarepartofthesection,tobeperformed.
PerformingaPARAGRAPHwillcauseonlythatparagraphtobeperformed.
19.WhatistheuseofEVALUATEstatement?
EvaluateislikeacasestatementandcanbeusedtoreplacenestedIfs.ThedifferencebetweenEVALUATEandcaseisthatno'break'isrequiredforEVALUATEi.e.controlcomesoutoftheEVALUATEassoonasonematchismade.
20.WhatarethedifferentformsofEVALUATEstatement?
EVALUATEEVALUATESQLCODEALSOFILE-STATUS
WHENA=BANDC=DWHEN100ALSO'00'
imperativestmtimperativestmt
WHEN(D+X)/Y=4WHEN-305ALSO'32'
imperativestmtimperativestmt
WHENOTHERWHENOTHER
imperativestmtimperativestmt
END-EVALUATEEND-EVALUATE
EVALUATESQLCODEALSOA=BEVALUATESQLCODEALSOTRUE
WHEN100ALSOTRUEWHEN100ALSOA=B
imperativestmtimperativestmt
WHEN-305ALSOFALSEWHEN-305ALSO(A/C=4)
imperativestmtimperativestmt
END-EVALUATEEND-EVALUATE
21.HowdoyoucomeoutofanEVALUATEstatement?
Aftertheexecutionofoneofthewhenclauses,thecontrolisautomaticallypassedontothenextsentenceaftertheEVALUATEstatement.Thereisnoneedofanyextracode.
22.InanEVALUATEstatement,canIgiveacomplexconditiononawhenclause?
Yes
23.Whatisascopeterminator?
Giveexamples.
Scopeterminatorisusedtomarktheendofaverbe.g.EVALUATE,END-EVALUATE;IF,END-IF.
24.Howdoyoudoin-linePERFORM?
PERFORM......
ENDPERFORM
25.Whenwouldyouusein-lineperform?
Whenthebodyoftheperformwillnotbeusedinotherparagraphs.Ifthebodyoftheperformisagenerictypeofcode(usedfromvariousotherplacesintheprogram),itwouldbebettertoputthecodeinaseparateparaandusePERFORMparanameratherthanin-lineperform.
26.WhatisthedifferencebetweenCONTINUE&NEXTSENTENCE?
CONTINUEislikeanullstatement(donothing),whileNEXTSENTENCEtransferscontroltothenextsentence(!
!
)(Asentenceisterminatedbyaperiod)
27.WhatdoesEXITdo?
Doesnothing!
Ifused,mustbetheonlysentencewithinaparagraph.
28.CanIredefineanX(100)fieldwithafieldofX(200)?
Yes.Redefinesjustcausesbothfieldstostartatthesamelocation.Forexample:
01WS-TOPPICX
(1)
01WS-TOP-REDREDEFINESWS-TOPPICX
(2).
IfyouMOVE'12'toWS-TOP-RED,
DISPLAYWS-TOPwillshow1while
DISPLAYWS-TOP-REDwillshow12.
30.WhatdoyoudotoresolveSOC-7error?
Basicallyyouneedtocorrectingtheoffendingdata.
ManytimesthereasonforSOC7isanun-initializednumericitem.Examinethatpossibilityfirst.
Manyinstallationsprovideyouadumpforruntimeabends(itcanbegeneratedalsobycallingsomesubroutinesorOSservicesthruassemblylanguage).Thesedumpsprovidetheoffsetofthelastinstructionatwhichtheabendoccurred.ExaminethecompilationoutputXREFlistingtogettheverbandthelinenumberofthesourcecodeatthisoffset.Thenyoucanlookatthesourcecodetofindthebug.Togetcapturetheruntimedumps,youwillhavetodefinesomedatasets(SYSABOUTetc)intheJCL.
Ifnoneofthesearehelpful,usejudgementandDISPLAYtolocalizethesourceoferror.
Someinstalltionmighthavebatchprogramdebuggingtools.Usethem.
31.HowissignstoredinPackedDecimalfieldsandZonedDecimalfields?
PackedDecimalfields:
Signisstoredasahexvalueinthelastnibble(4bits)ofthestorage.
ZonedDecimalfields:
Asadefault,signisoverpunchedwiththenumericvaluestoredinthelastbite.
32.Howissignstoredinacomp-3field?
Itisstoredinthelastnibble.Forexampleifyournumberis+100,itstoreshex0Cinthelastbyte,hex1Cifyournumberis101,hex2Cifyournumberis102,hex1Difthenumberis-101,hex2Difthenumberis-102etc...
33.HowissignstoredinaCOMPfield?
Inthemostsignificantbit.Bitisonif-ve,offif+ve.
34.WhatisthedifferencebetweenCOMP&COMP-3?
COMPisabinarystorageformatwhileCOMP-3ispackeddecimalformat.
35.WhatisCOMP-1?
COMP-2?
COMP-1-Singleprecisionfloatingpoint.Uses4bytes.
COMP-2-Doubleprecisionfloatingpoint.Uses8bytes.
36.HowdoyoudefineavariableofCOMP-1?
COMP-2?
Nopictureclausetobegiven.Example01WS-VARUSAGECOMP-1.
37.HowmanybytesdoesaS9(7)COMP-3fieldoccupy?
Willtake4bytes.Signisstoredashexvalueinthelastnibble.
GeneralformulaisINT((n/2)+1)),wheren=7inthisexample
38.HowmanybytesdoesaS9(7)SIGNTRAILINGSEPARATEfieldoccupy?
Willoccupy8bytes(oneextrabyteforsign).
39.HowmanybyteswillaS9(8)COMPfieldoccupy?
4bytes
40.WhatisthemaximumvaluethatcanbestoredinS9(8)COMP?
99999999
41.WhatisCOMPSYNC?
Causestheitemtobealignedonnaturalboundaries.CanbeSYNCHRONIZEDLEFTorRIGHT.
Forbinarydataitems,theaddressresolutionisfasteriftheyarelocatedatwordboundariesinthememory.Forexample,onmainframethememorywordsizeis4bytes.Thismeansthateachwordwillstartfromanaddressdivisibleby4.Ifmyfirstvariableisx(3)andnext
oneiss9(4)comp,thenifyoudonotspecifytheSYNCclause,S9(4)COMPwillstartfrombyte3(assumingthatitstartsfrom0).IfyouspecifySYNC,thenthebinarydataitemwillstartf
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- COBOL 面试 问题 大全