Which two code fragments should you use at line n1, independently, to achieve this requirement?

You are developing a banking module. You have developed a class named ccMask that has
a maskcc method. Given the code fragment: You must ensure that the maskcc method
returns a string that hides all digits of the credit card number except the four last digits (and
the hyphens that separate each group of four digits). Which two code fragments should you
use at line n1, independently, to achieve this requirement?

You are developing a banking module. You have developed a class named ccMask that has
a maskcc method. Given the code fragment: You must ensure that the maskcc method
returns a string that hides all digits of the credit card number except the four last digits (and
the hyphens that separate each group of four digits). Which two code fragments should you
use at line n1, independently, to achieve this requirement?

A.
Option B

B.
Option C

C.
Option D

D.
Option A

Explanation:



Leave a Reply 4

Your email address will not be published. Required fields are marked *


IO

IO

A.
Option B
B.
Option C

Kaykay

Kaykay

Definitely A – Option B and B – Option C

Tomas

Tomas

Answers: A (option B) and B (option C)

// A // wrong

StringBuilder sb = new StringBuilder(creaditCard);
sb.substring(15, 19);
return x + sb; // XXXX XXXX XXXX 1234-5678-9101-1121

// B // OK
//return x + creaditCard.substring(15, 19); // XXXX XXXX XXXX 1121

// C // OK
/*
StringBuilder sb = new StringBuilder(x);
sb.append(creaditCard, 15 , 19);
return sb.toString(); // XXXX XXXX XXXX 1121
*/

// D // wrong
/*
StringBuilder sb = new StringBuilder(x);
StringBuilder s = sb.insert(0, x);
return s.toString(); // XXXX XXXX XXXX XXXX XXXX XXXX
*/