What is the output of the following program? import java util. Scanner; public c
ID: 3821958 • Letter: W
Question
What is the output of the following program? import java util. Scanner; public class Q_10 {public static void main (String[] args) {int ans = 35, x = 50, y = 50; if(x > y){ans = x + 10; x = y;} else{ans = y + 10; y+ = x;} System out println(" x = " +x); System.out.println(" y = " +y); System.out.println(" ans = " + ans);}} What is the output of the following program? public class Q_11 {public static void main(String[] args) {String s1 = " abc"; String s2 = " def"; String s3 = s1; s2 = " xyz"; System.out.println(s1 + " " + s2 + " " + s3);}} What is the output of the following program? public class Q_07{(public static void main(String [] args){int yi1 = 5; String s1 = " 7"; int i2 = 6; System.out.println(i1 + i2 + s1);}}Explanation / Answer
Question 11:
Answer:
x = 50
y = 100
ans = 60
How?
else conditin pass where x <
ans = y + 10 ; ==> 50 + 10
y += x; ==> 50 + 50
Question 12:
Answer:
abc
xyz
abc
How?
String s3 = s1; // assign abc to s3
s2 = "xyz"; // change def to xyz
Question 13:
Answer:
x = 10 y = 5
HOW?
x incremented for 2 * 5 = 10 times
y incremented for 5 = 5 times
Question 14:
Answer:
117
How?
i1 + i2 + s1
here i1 and i2 are integer and s1 is string
firstly i1 and i2 are added 5 + 6 = 11
s1 is concated to resutl of i1 + i2
11 + "7"
117
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.