Multiple choice technology programming languages

data: begin of itab occurs 0, field1(10), field2(10), end of itab. Move: 'A' to itab-field1, 'B' to itab-field2. Append itab. Append itab. Move: 'B' to itab-field1. Append itab. Clear itab. Move: 'A' to itab-field2. Append itab. What are the contents of itab after executing the above code? a) A B A B B B A b) A B A B B A c) A B B A d) A B B A A e) A B B A B A B A

  1. a

  2. b

  3. c

  4. d

  5. e

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code builds a table through a sequence of MOVE and APPEND operations. First it adds 'A','B' twice (lines 1-2). Then it changes field1 to 'B' and appends a third line 'B','B'. After CLEAR itab, the header is 'B','B' (last appended). The final MOVE sets field2 to 'A', so the fourth line is 'B','A'. Result: A B, A B, B B, B A. The CLEAR empties the body but header retains the last line's values until overwritten.

AI explanation

To determine the contents of the itab internal table after executing the given code, let's go step by step:

  1. Move: 'A' to itab-field1, 'B' to itab-field2. - This moves the values 'A' and 'B' to itab-field1 and itab-field2 respectively. So, itab now contains one entry with field1 as 'A' and field2 as 'B'.

  2. Append itab. - This appends the current contents of itab to itab. So, itab now contains two entries with field1 as 'A' and field2 as 'B'.

  3. Append itab. - This appends the current contents of itab to itab again. So, itab now contains three entries with field1 as 'A' and field2 as 'B'.

  4. Move: 'B' to itab-field1. - This moves the value 'B' to itab-field1. So, the first entry in itab now has field1 as 'B' and field2 as 'B'.

  5. Append itab. - This appends the current contents of itab to itab. So, itab now contains four entries with field1 as 'B' and field2 as 'B'.

  6. Clear itab. - This clears the contents of itab.

  7. Move: 'A' to itab-field2. - This moves the value 'A' to itab-field2. So, the first entry in itab now has field1 as 'B' and field2 as 'A'.

  8. Append itab. - This appends the current contents of itab to itab. So, itab now contains one entry with field1 as 'B' and field2 as 'A'.

Therefore, the contents of itab after executing the code are:

A B B A

So, the correct answer is A.