Home / Questions / 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())));
Explanatory Question

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())));

👁 79 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

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.