State the output of the following program segment:

String str1 = "great"; String str2 = "minds";
System.out.println(str1.substring(0,2).concat(str2.substring(1)));
System.out.println(("WH" + (str1.substring(2).toUpperCase())));

Views 10

Answer:

The final value stored in variable x is 6.0 and y is 15.0.

Explanation:

  1. Math.ceil(a) gives -6.0 and Math.abs(-6.0) is 6.0.
  2. Math.max(a,b) gives 14.74 and Math.rint(14.74) gives 15.0.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.