Consider the following program and predict the output:
public class Main { public static void main(String []args) { String s = new String("5"); System.out.println(1.0+10.5+s+(1.0+10.5)); } }
a)
The rule specified in the earlier explanation applies here also.
However, here, the order of computation is changed using brackets.
Hence, the + operator adds the numbers in the brackets first, and you get 11.5511.5.