Hi, I have a question about String and StringBuilder.
The task is:
Assuming that the following method will always be called with a phone number in the format ddd-ddd-dddd (where d stands for a digit), what can be inserted at //1 so that it will return a String containing the same number except its last four digits will be masked with xxxx?
one of the correct answers is: return new StringBuilder(fullPhoneNumber).substring(0, 8)+"xxxx".
My question is: is it always ok to return StringBuilder if in the method the return type is String?
2: One of the operands for the String concatenation operator + is a String already ("xxxx"). That means it can take any operand on the other side and turn it into a String and the whole expression is of type String. That means anything except a method call returning void.