What is the output generated by the following code?
01 GRP-I.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
ELSE
DISPLAY "SPACES"
DISPLAY "END".
(a) SUBFLD1
SUBFLD3
END
(b) SPACES
END
(c) SUBFLD1
END
(d) SUBFLD1
SPACES

Answers were Sorted based on User's Feedback



What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / guest

a

Is This Answer Correct ?    5 Yes 0 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / vish

I doubt if we can code like IF ELSE ELSE....since no scope
terminatior (END-IF) has been given for the nested IF ELSE
so it should throw a compilation error. It can display the
output as (a) ONLY if the code is something like below:

01 GRP-1.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
END-IF
ELSE
DISPLAY "SPACES"
DISPLAY "END".

Please correct me if I am wrong.

Is This Answer Correct ?    5 Yes 1 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / ajith

(a)

Is This Answer Correct ?    2 Yes 0 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / vish

Uttam, I guess you missed to see the REDEFINES part of the
code given. It's moving 'ABBCCD' to GRP-1 and since GRP-2
REDEFINES GRP-1, the variables in GRP-2 also will be
populated and then naturally SUB-FLD3 is not SPACES and
contain 'BC'. So the correct answer is (a).

I request - please don't be in hurry to answer the
questions. A lot many people build their concepts based on
the questions & queswers provided in such groups.

Is This Answer Correct ?    2 Yes 0 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / guest

I hope SUBFLD1 is erroneously written as SUB-FLD1

Is This Answer Correct ?    0 Yes 0 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / muttaiah

I guess we will get Maxcc - 8 when we compile. Because
SUB-FLD1 is not declared anywhere here. If the field has to
be SUBFLD1 by typo mistake.
Then answer would be (a).

Is This Answer Correct ?    0 Yes 0 No

What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "A..

Answer / uttam das

my answer is (d)

SUB-FLD3 = SPACES, it satisfies bcz in grp-2

there is no initialization of sub-fld3.
when sub-fld3 is not initialize, it always contains spaces.
alphanumeric stored spaces and numeric stored zeros

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More COBOL Interview Questions

How to resolve the soc4 & soc7 other than following answers. Soc4 can resolved using mispleed dd name and dd name is not matching with file and soc7 check the sysdump and copy the offest address then correct it in the program.

10 Answers   ADP, Amdocs, Cap Gemini, Keane India Ltd, Super Value, TCS,


Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc

0 Answers  


What should be the sorting order for SEARCH ALL?

5 Answers  


Mention the guidelines to write a structured cobol program?

0 Answers  


how will u find out 3rd week's 2nd day using occurs ?

3 Answers   L&T,






What is the difference between COMP & COMP-3 ?

2 Answers  


What is a subscript ?

3 Answers  


Define REDEFINE clause and Is it possible to have the redefine clause anywhere in the working storage section for a data name?

3 Answers  


SSRange is used to do a range check on which of the Following. SUBSCRIPT,INDEX,REFERENCE MODIFICATION,Run-time option.

3 Answers   Lehman Brothers,


Hi, My interviewer ask A calls B and C calls B, a and b are static c and b are dynamic.what happens if they compile and execute at same time.

3 Answers   iGate,


What is mean by maxcc

7 Answers   Syntel,


wht is load module and object module ?

2 Answers   DELL, TCS,


Categories