Question 42 of 76 from exam 1Z0-808: Java SE 8 Programmer I

Question 42 of 76 from exam 1Z0-808: Java SE 8 Programmer I

Question

You are developing a banking module.

You have developed a class named ccMask that has a maskcc method.

Given the code fragment:

class CCMask {
public static string maskcc (string creditcard) {
String x = "KXXX-XXXK-KXKX-"7
f/fline nl
3

public static void main(string[] args) {
System. out. print1n (maskCc ("1234-5678-9101-1121") );
3

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?

O A) stringBuilder sb = new StringBuilder (creditCard) ;
sb.substring(15, 19);
return x + sb;

OB) return x + creditCard.substring(15, 19);

OC) stringBuilder sb = new StringBuilder (x);
sb. append (creditcard, 15, 19);
return sb.toString();

OD) stringBuilder sb = new StringBuilder (creditCard) ;
StringBuilder s = sb.insert (0, x);
return s.toString();

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

BC.