SAP Certified Associate Back End Developer ABAP Cloud · Free Practice Question Hard
Question 19
Given this code,
- DATA: go_super TYPE REF TO lcl_super,
- go_sub1 TYPE REF TO lcl_sub1,
- go_sub2 TYPE REF TO lcl_sub2.
- go_super = NEW go_sub2(...).
- go_super = NEW go_sub1(...).
- go_sub1 = CAST #( go_super ).
- go_sub1->sub1_meth1(...).
- go_sub2 = CAST #( go_super).
- go_sub2->sub2_meth1(...).
With Icl_super being superclass for Icl_sub1 and Icl_sub2 and with methods sub1_meth1 and sub2_meth1 being subclass-specific methods of Ic_sub1 or Icl_sub2, respectively.
What will happen when executing these casts? (2 correct)
-
A
go_sub1->sub1_meth 1(…). will work.
-
B
go_sub1 = CAST #( go_super ), will not work
go_sub2 = CAST #( go_super ), will work.
-
C
go_sub2->sub2_meth 1(...). will work
-
D
go_sub1 = CAST #( go_super ), will work
go_sub2 = CAST #( go_super ). will not work.
Reveal correct answers
Correct answers: A, D
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
