About Question enthuware.ocajp.i.v8.2.1445 :
Posted: Wed Jan 11, 2017 11:13 am
Hi Paul!
I have a little doubt in the following question:
This option is marked as correct:
Can I just assume that substring returns an String and that's why the hidePhone method it's accepting it?
Because at first I thought that it would throw an exception, because you can't pass an StringBuilder to a method that is asking for a String.
I have a little doubt in the following question:
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 "xxx-xxx-"+dddd, where dddd represents the same four digits in the original number?
Code: Select all
public static String hidePhone(String fullPhoneNumber){
//1 Insert code here }
Code: Select all
return new StringBuilder("xxx-xxx-")+fullPhoneNumber.substring(8);
Because at first I thought that it would throw an exception, because you can't pass an StringBuilder to a method that is asking for a String.