String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd)); 1) Bic 2) ic 3) icy 4) error: no method matching substring(int,char) The answer is (4). Does the char value always get converted to int, even in the case of substring function?
Hi geeta, the answer is 2 and not 4 as you pointed out. The 'char' datatype is implicitly casted to 'int' since 16-bit fits perfectly in 32-bit. The signatures for the substring method are: 1) substring (int beginIndex) 2) substring (int beginIndex, int endIndex) Hope this helps.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!