0% found this document useful (0 votes)
61 views7 pages

COBOL Sample Test

The document contains a series of questions and answers related to COBOL programming, UNIX commands, and SQL. It covers various topics including COBOL syntax, file handling, data types, UNIX command functionalities, and SQL query structures. Each section is designed to test knowledge and understanding of these programming concepts.

Uploaded by

Csm32Nithin.M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views7 pages

COBOL Sample Test

The document contains a series of questions and answers related to COBOL programming, UNIX commands, and SQL. It covers various topics including COBOL syntax, file handling, data types, UNIX command functionalities, and SQL query structures. Each section is designed to test knowledge and understanding of these programming concepts.

Uploaded by

Csm32Nithin.M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SECTION I-COBOL (Programming & Concepts):

Q1-Which is the mandatory division in COBOL program?


A- PROCEDURE
ENVIRONMENT B-IDENTIFICATION C_DÄTA
Q2-How is sign stored in a COMP-3 field?
A- First Bit B-Last Bit CFirst Nibble D-Last Nibble
Q3-What will happen if youcode GO BACK instead of
A- Program will give run time emOr. STOPRUN in a stand alone COBOL program?
CProgram will execute normally. B_Program will go in infinite loop.
DProgram will throw compilation error.
Q4-What is the maximum size of anumeric field we can define in
A- 9(20) COBOL?
B-9(18) C9(3) D=9(10)
Q5 What is the mode in which you will OPEN a file for
A- OUTPUT writing?
B- EXTEND
C-Either OUTPUT or EXTEND D-INPUT-OUTPUT
Q6-Where does the FILE-CONTROL paragraph appear?
A-Procedure Division BEnvironment Division
C-ldentification Division D-Data Division
Q7_Can Iredefine an X10 ffeld with a field of X202
ANo B Yes
Q8-What is the length of PIC 9.999?
A-4 B_6 C5 D3
Q9- Which cobol verb is used for updating afile?
A_READ B-WRITE cUPDATE D REWRITE
Q10- If 436 value is moved to a PP999 PIC clause, then what is edited value taken?
A-00436 B 00436 C436 Het D43600
Q11-Nhere can we specify OCCURS clause?
AElementary lten B_Group Item C- Both A&B D None ofthese
Q12-What does SEARCH ALL do?
A-Linear search B Binary 'search
C-Sequential search D None of these
Q13- In which division, Linkage Section comes?
A-ldentification Division B_Environment Division
CData Division D_Procedure Division
Q14- Which level number we should use for RENAMES clause?
A-77 B_49 C_66
Q15-Which level number we should use for conditions?
AT7 B-88 G01 D-66
Q16-What is the output of following program?
IDENTIFICATION DIVISION.
PROGRAM-HD. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC X(4) VALUE '15AB'.
PROCEDURE DIVISION.
MOVE XXXX TO WS-NUM1
DISPLAY WS-NUM1.
STOP RUN.
B-XXXX CCompilation eror D-Run time error
A-15AB
Q17-What is the output of following program?
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTnON.
01 WSJD PIC 9(5)
PROCEDURE DIVISiON.
A000-FIRST-PARA.
INITIALIZE WSJD REPLACING NUMERIC DATA BY 12345.
DISPLAY WS ID.
STOP RUN.
A-00000 B 12345 CSpaces Dompilation error

Q18-What is the output of the following code?


IDENTIFICATION DIVISION
PROGRAM HD. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION,
01 WS-NUMT PIC 9(9)
01 WS-NUM2 PIC 9(6).
PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 123456789 TO ws-NUM1.
MOVE WS-NUM1(3:6) TO WS-NUM2,
DISPLAY WS-NUM2
STOP RUN:
A 456789 B000000 C 123456 D 345678

Q19-Moving a Numeic field to Alphabelic is legal?


A Yes BNo
20-Moving a Numericfield to Alphanumeric is lega?
A- Yes BNo
021-Moving a Alpbabelig field to Alphanumeric islegal?
AYes BNo
Q22-What is the output of following program?
IDENTIFICATION DIVISION.
PROGRAMID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01WS-NUMA PIC 9(9) VALUE 10.
01 WS-NUMB PIC 9(9) VALUE 10.
01 WS-NUMC PIC 9(9) VALUE 10
01 WS-NUMD PIC9(9) VALUE 100,
01 WS-NUMEPIC 9/9) VALUE 10
PROCEDURE DIVISION.
sUBTRACT WSNUMA WS-NUMBWS-NUMC FROMWS-NUMD GIVING WS-NUNE
DISPLAY WS-NUME
STOP RUN.
A-000000100 B 000000090 C-000000070 D-000000080
a23- What is the output of following program?
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DESCRIPTION,
05 WS-NUM.
10 WS-NUM1 PIC 9(2)VALUE 20.
10 WS-NUM2PIC 9(2)VALUE 56.
L

05 WS-CHAR.
10 WS-CHAR1 PIC X(2) VALUE 'AA'.
10 WS-CHAR2 PIC X(2) VALUE 'BB'.
10 WS-RENAME RENAMES WS-NUM2 THRU Ws-CHAR2.
PROCEDURE DIVISION.
DISPLAY "WS RENAME" WS-RENAME
STOP RUN.
A- 56AABB B_Compilation Eror C_Space D_Zeroes

Q24- How many bytes S96 USAGE IS COMP willtake?


A-6 B4 C3 D2
Q25 How many bytes S96 USAGE IS COMP-3 willtake?
Ax6 B3 D_7
Q26- How many times following Flpara loop willexecute?
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING STORAGE SECTION.
01 WS PIC 9VALUE 0.
PROCEDURE DIVISION.
A-PARA,
PERFORM B-PARA VARYING WS-AFROM 1 BY 1UNTIL WS-A=5
STOP RUN.
B-PARA.
DISPLAY IN B-PARA' WS-A
A5 B_4 D6
027- What is the output of following program?
IDENTIFICATION DVISION.
PROGRAM ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-CNT PIC 9(2) VALUE0.
01 WS-STRING PIC X(15)VALUE 'AABCDACDAAEAAAF.
PROCEDURE DIVISION.
INSPECT WS-STRINGTALLYING WS-CNT FOR ALL 'A'. DISPLAY WS-CNT
STOP RUN.
A-09 B06 Q08 D 10
Q28-Set statement is used to change the index value. Set verb is used to initialize, increment or decrement the
index value. Is this statement true or false?
A-False BTrue
Q29-Search is a binary search method, which is used to find elements inside the table. is this statement true or
false?
A: True B-False

Q30 Which command is used to place the cursor on a specific record?


AOpen B Start CRead next D-Write

a31For deleting a record, in which mode we should open the file?


A_ Input-Output B Input COutput D-Extend
Q32- If the values of variables in the called program are modified, then their new values will refiect in the calling
program. What type of call is this?
A- Callby content BCall by reference CNone of these
Q33- In which usage, data item is similar to Real or Float and is represented as a single precision floating point
number and internally data is stored in hexadecimal format?
A- COMP B_COMP-3 C-COMP-2 DCOMP-1
Q34- In which usage, data item is similar to Long or Double and is represented as double precision floating
number and internally data is stored in hexadecimal format? point
Az COMP BCOMP-3 CcOMP DCOMP-1
Q35- In which usage, data item is stored in pack decimal format and each digit occupies half abyte 1nibble and the
sign is stored at the right most nibble?
A- COMP BCOMP-3 CCOMP-2 D-COMP-1
Q36 - Which verb is used to count or replace the characters in astring?
A-Count B-Inspect C Replace D Add
Q37- Which option is used in Inspect verb to replace the string characters?
A: Count B Tallying C- Replacing DAdd
Q38- What is the output of following program?
IDENTIFICATION DIVISICN.
PROGRAM-ID. HELLO
DATA DIVISION.
WORKING-STORAGE SECTION
01 WS-STRING PIC A(30).
01 WS-STR1 PIC A(15) VALUE'SB-CIE!
01 WS-STR2 PIC A() VALUE Welcome'
01 WS-STR3 PIC A(7) VALUE To AND'
01 WS-QOUNT PIC 99 VALUE 1
PROCEDURE DIVIsION.
STRING Ws-STR2 DELIMITED BY SIZE
Ws-STR3 DELIMITED BY SPACE
WS-STR1 DELIMITED BY SIZEINTO W$-STRING
WITH POINTER W^-cOUNT ON OVERFLOW DISPLAY OVERFLOWI
END-STRING.
DISPLAY WS-STRING: WS STRING
STOP RUN.
AWelcomeTo B-Welcone ToSEI-GIE
C Welcome SB-CIE D None of Above
Q39-Which statementwe should not use incalled program?
A: Linkage Section BProcedure Division Using
Cz Stop Run DExit Program
Q40- In which division we declare our variables?
A- PROCEDURE DIVISION. BIDENTIFICATION DIMISION
C-DATA DIVISION DENVIRONMENT biVISION
Q41- In whích division we write logic of the program?
A-PROCEDURE DIVISION. B-IDENTIFIÇATION DIVISION
CDATA DIVISION D ENVIRONMENT DIVISION
Q42- In which mode you willopen the sequential file to append the data in the end.
A- APPEND B-INPUT CzOUTPUT D EXTEND
Q43- What is the length of a variable when usage is COMP-1?
A 16 8.2 G8 D-4

Q44- What is the length of a variable when usage is COMP-2?


A2 B 16 D-8

Q45- What is the length of PIC $97V99 COMP-3?


Az 10 B9 C4 D-5
Q46- What is the length of PIC 999V9?
A-6 B-5 C3 D4
Q47 -What is AREA in COB0L Program. Kindly Explain the name and lenght details.
Q48-How many ways you can initialize a variable?

Q49- What is the section that is used to recieve the data from outside of the program?
numbers?
Q50 -Can we declare two variables with same name and same level

Q51-Can Ideclare a variable without PIC clause? How?


Q52- What is the output of below code?
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAL PIC 9(03).
PROCEDURE DIVISION.
MOVE 99000 TOWS-VAL
DISPLAY WS-VAL
STOP-RUN.

Q53- What is the output of below code?


DATA DIVISION."
WORKING-STORAGE SECTION.
01 WS-SALARY PIC 9(05) VALUE 50000.
PROCEDURE DIVISION.
IF WS-SALARY GREATER THAN 40000
CONTINUE
ELSE
COMPUTE WS-SALARY = WS-SALARY + 20000
ENDIF.
COMPUTE WS SALARY= WS-SALARY + 30000
DISPLAY "SALARY:" WS-SALARY
STOP-RUN.

Q54- What is the output of below code?


WORKING-STORAGE SECTION.
01 WS-QRG.
03 WS-EMP QCQURE 6 TIMES INDEXEDBY IDX-EMP.
05 WS-EMP-NUM PIC X(05).
PROCEDURE DIVISION.
MOVE 'EO005E0002E0004E0001E00057' TO WS-QRG.
SET IDX-EMP T0 4.
SEARCH WS-EMP VARYING IDX-EMP AT END DISPLAY"Employee not found
WHEN WS-EMP-NUM(IDX-EMP) ='E0O02"
DISPLAY'Employee found'
END-SEARCH.

Q55- What do you understand by static and dynamic linkage?


Q56-How is INCLUDE different from COPY?

SECTION 2 - UNIX Commands:


Q1: Which command is used to display the current directory in UNIX?
A-pwd BIs C-cd Ddir

02: Which UNIX command is used to create a new directory?


A- touch B- mkdir Gmdir D-cp

03: Which UNIX command is used to remove a file?


B-mv C- delete erase
A-m

Q4: What does the chmodcommand do in UNIX?


A- Changes the owner of a file BChanges the permissions of afile
C- Modifies the file content D- Deletes a file
Q5: Which command is used to terminate a process in UNIX?
A- end B kill G-stop D-quit
Q6: Which command is used to copy files in UNIX?
B-mv D-copy
Q7: What is the pupose of the grep command in UNIX?
A Tofind and display lines in a file that match a pattern B-Tolistthe files in a directory
C- To remove files fromi the system D-To count the number of linesin a file
Q8: Which command in UNIX is used to searchfor a specific patter in files?
A-grep B- ind Clocate search
Q9: What does the touch cormmand do in UNIX?
A- Creates a new, empty file B Changesfile pemissions
C Displays file content DMoves files between directories
Q10: What is the purpose of the gzip command in UNIX?
A-To compress file B- Toextract files C-To display contents
SECTION 3- SQL
Q1: What is the difierehce between drop, delete and truncate?
Q2: Which SQL statement is used to extract data froma database?
A- SELECT B- EXTRACT C_OPEN DGET
Q3: Which SQL statement is used to insert newdata in adatabase?
AADD NEW B- INSERT INTO CINSERT NEW DADD RECORD

Q4: With sQL, how do you select allthe records from a table named "Persos" where the value of the column
"FirstName" is "Peter"?
A- SELECT [al] FROM Persons WHERE FirstName LIKE Peler
B-SELECTFROM Persons WHERE FirstName ='Peter
C- SELECT [allj FROM Persons WHERE FisName ='Peter
D- SELECT*FROM Persons WHERE FirstName <> 'Peter
Q5:Which of the following commands are used to put a restriction on the number of rows returned from a query?
A-LIMIT B-LIKE C-WHERE DGROUP BY
Q6: Primary key can be?
A-NULL B-NOT NULL C- Both NULL and NOT NULL, D- Depends on situation
Q7-Consider the foliowing schema
STUDENTS(studentcode, first_name, last_name, email,
phone_no, date_of_bith, honours_subject, percentage_of_marks);
Which of the following query would display names of allstudents in descending order of percentage of marks?
A-select irst_name, last name, percentage_of marks from students order by percentageof_marks;
B-select first_name, last name, percentage_of_marks order by percentage_of_marks desc from students:
C select first name, last name, percentage_of_marks from students order by percentage of marks desc
D select first_ name, last name, percentage_of_marks from students order by percentage o marks descending
Q8-Consider the following schema -
HONOURS_SUBJECT(subject_code, subject_name, department _head);
LOCATIONS(subject_code,department_name, location_id, city).;
Which query will perform analural join between the HONOURS_SUBJECT table andthe LOCATIONS lable?
Aselect subject_code, subject_name, location_ id, city from honours_subject cross join locations,
Bselect subject_code, subject_name, location_ id, city from honours_subject join locations
Czselect subject_code, subject_name, location_id, city from honours_subject outer join localions,
Dz seleci subject_code, subjecl_ name, location_ id, city from honours_subject natural join locations
Q9:Which SQL statement is used to return only different values?
A- SELECT UNIQUE B-SELECT DIFFERENT C- SELECT DISTINCT
Q10: The NOT NULL Constraint enforces a column to not accept NULLvalues
A- FALSE B-TRUE
SECTION4- General:
Q1- Please explain the CIF opening flow with programs and table?
Q2- Write debugging steps for online and offline both?

You might also like