COBOL Mock Test


Advertisements

This section presents you various set of Mock Tests related to COBOL Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

COBOL Mock Test IV

Q 1 - 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

D - COMP-1

Answer : D

Explanation

COMP-1 is represented as a single precision floating point number and data is internally stored in hexadecimal format.

Q 2 - In which usage, data item is similar to Long or Double and is represented as double precision floating point number and internally data is stored in hexadecimal format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : C

Explanation

COMP-2 is represented as double precision floating point number and internally data is stored in hexadecimal format.

Q 3 - In which usage, data item is stored in pack decimal format and each digit occupies half a byte (1 nibble) and the sign is stored at the right most nibble?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : B

Explanation

This statement is self explanatory.

Q 4 - Which verb is used to count or replace the characters in a string?

A - Count

B - Inspect

C - Replace

D - Add

Answer : B

Explanation

Inspect verb is used to count or replace the characters in a string. String operations can be performed on alphanumeric, numeric, or alphabetic values. Inspect operations are performed from left to right.

Q 5 - Which option is used in Inspect verb to replace the string characters?

A - Count

B - Tallying

C - Replacing

D - Add

Answer : C

Explanation

Replacing option is used to replace the string characters.

Q 6 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30).
   01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'.
   01 WS-STR2 PIC A(7) VALUE 'Welcome'.
   01 WS-STR3 PIC A(7) VALUE 'To AND'.
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   STRING WS-STR2 DELIMITED BY SIZE
      WS-STR3 DELIMITED BY SPACE
      WS-STR1 DELIMITED BY SIZE
      INTO WS-STRING 
      WITH POINTER WS-COUNT
      ON OVERFLOW DISPLAY 'OVERFLOW!' 
   END-STRING.
   
   DISPLAY 'WS-STRING : 'WS-STRING.
   
STOP RUN.

A - WelcomeTo

B - WelcomeToTutorialspoint

C - WelcomeTutorialspoint

D - WelcomeTopoint

Answer : B

Explanation

String command is used to concatenate the strings.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30).
   01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'.
   01 WS-STR2 PIC A(7) VALUE 'Welcome'.
   01 WS-STR3 PIC A(7) VALUE 'To AND'.
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   STRING WS-STR2 DELIMITED BY SIZE
      WS-STR3 DELIMITED BY SPACE
      WS-STR1 DELIMITED BY SIZE
      INTO WS-STRING 
      WITH POINTER WS-COUNT
      ON OVERFLOW DISPLAY 'OVERFLOW!' 
   END-STRING.
   
   DISPLAY 'WS-STRING : 'WS-STRING.
   
STOP RUN.

Q 7 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

A - WelcomeTo

B - To

C - Tutorialspoint

D - point

Answer : B

Explanation

Unstring verb is used to split one string into multiple sub-strings.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

Q 8 - Which statement we should not use in called program?

A - Linkage Section

B - Procedure Division Using

C - Stop Run

D - Exit Program

Answer : C

Explanation

We should not use Stop Run in called program as the calling program is expecting the control back. Stop run will end the execution and will return the control back to operating system.

Q 9 - Two or more identically sequenced files are combined using Merge statement. State whether true or false?

A - True

B - False

Answer : A

Explanation

This statement is correct.

Answer : C

Explanation

In Data Division we declare all the working storage variables.

Q 11 - Which division provides information of external data sets used in the program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Answer : D

Explanation

In file control paragraph inside Environment division we mention all the information of external data sets used in the program.

Answer : A

Explanation

Procedure division is used to include the logic of the program. It consists of executable statements using variables defined in the data division. In this division, paragraph and section names are user-defined.

Q 13 - In which mode you will open the sequential file to append the data in the end.

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Answer : D

Explanation

Sequential file is opened in Extend mode to append the data at the end. If you will open the file in Output mode it will delete all the existing data and then write the data.

Answer : A

Explanation

01-07 are reserved for line numbers.

Q 15 - Where does Identification Area in COBOL starts from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Answer : D

Explanation

Identification area is used as needed by the programmer.

Q 16 - What is the length of a variable when usage is COMP-1?

A - 16

B - 2

C - 8

D - 4

Answer : D

Explanation

COMP-1 takes 4 bytes of storage.

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

A - 2

B - 16

C - 4

D - 8

Answer : D

Explanation

COMP-2 takes 8 bytes of storage.

Q 18 - What is the length of PIC S9(7)V99 COMP-3?

A - 10

B - 9

C - 4

D - 5

Answer : D

Explanation

(9+1)/2 = 5 bytes.

Q 19 - What is the length of PIC S9(7) COMP?

A - 7

B - 6

C - 5

D - 4

Answer : D

Explanation

If 'n' = 1 to 4, it takes 2 bytes.
If 'n' = 5 to 9, it takes 4 bytes.
If 'n' = 10 to 18, it takes 8 bytes

Q 20 - What is the length of PIC 999V9?

A - 6

B - 5

C - 3

D - 4

Answer : D

Explanation

It will take 4 bytes, V is Implicit decimal & will not hold any byte.

Q 21 - Elementary items cannot be divided further. Level number, Data name, Picture clause and Value clause (optional) are used to describe an elementary item. State whether true or false?

A - True

B - False

Answer : A

Explanation

This statement is correct.

Q 22 - Group items consist of one or more elementary items. Level number, Data name, and Value clause (optional) are used to describe a group item. Group level number is always 01. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is true.

Q 23 - Decimal point position can be used with numeric data. Assumed position is the position of decimal point and not included in the data. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

Q 24 - Sign condition is used to check the sign of a numeric operand. It determines whether a given numeric value is greater than, less than, or equal to ZERO. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

Q 25 - Class condition is used to check if an operand contains only alphabets or numeric data. Spaces are considered in ALPHABETIC, ALPHABETIC-LOWER, and ALPHABETIC-UPPER. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

Answer Sheet

Question Number Answer Key
1 D
2 C
3 B
4 B
5 C
6 B
7 B
8 C
9 A
10 C
11 D
12 A
13 D
14 A
15 D
16 D
17 D
18 D
19 D
20 D
21 A
22 B
23 B
24 B
25 B
cobol_questions_answers.htm
Advertisements