What is the result of the following program execution, given that 49 is an ASCII code for 1?

public class A {
    public static void main(String[] args) {
        
        byte[] a={ 49,50,51,52,53,54,55 };
        
        String b=new String(a);      // 1 
        System.out.println(b);
        
        String c=new String(a,2,4);  // 2
        System.out.println(c);
    }

}
Explanation
String class has a constructor that initializes it with an 8-bit array:
public String (byte bytes [], int offset, int length)

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback