Which function call returns 0?

Which function call returns 0?
A . Count_any_of ( val – ‘ABAP ABAP abap’ sub "AB" )
B . Count (val – ‘ABAP ABAP abap’ sub – ‘AB’ )
C . find_any_of (val = "ABAP ABAP abap’ sub = "AB")
D . find_any_not_of( val ‘ABAP ABAP abap’ sub = ‘AB’)

Answer: D

Explanation:

The function find_any_not_of returns the position of the first character in the string val that is not contained in the string sub. If no such character is found, the function returns 0. In this case, the string val contains only the characters A, B, and a, which are all contained in the string sub, so the function returns 0. The other functions return positive values, as follows:

Count_any_of returns the number of occurrences of any character in the string sub within the string val. In this case, it returns 8, since there are 8 A’s and B’s in val.

Count returns the number of occurrences of the string sub within the string val. In this case, it returns 2, since there are 2 AB’s in val.

find_any_of returns the position of the first character in the string val that is contained in the string sub. In this case, it returns 1, since the first character A is in sub.

Reference: String Functions – ABAP Keyword Documentation, Examples of String Functions – ABAP Keyword Documentation

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments