ect answerWhat will be the output of the following Java program?class java { public static void main(String args[]) { int var1 = 3; int var2 = 8; if ((var2 = 2) == var1) System.out.print(var2); else System.out.print(++var2); } }
Question
ect answerWhat will be the output of the following Java program?class java { public static void main(String args[]) { int var1 = 3; int var2 = 8; if ((var2 = 2) == var1) System.out.print(var2); else System.out.print(++var2); } }
Solution
The output of the program will be 3.
Here's the step by step explanation:
-
Two integer variables
var1andvar2are declared and initialized with the values 3 and 8 respectively. -
In the
ifcondition,var2is reassigned with the
Similar Questions
What is the output of this program? class A {public static void main(String args[]){ int var1 = 5; int var2 = 6; if ((var2 = 1) == var1)System.out.print(var2);else System.out.print(++var2); }}ans. 2314 Previous Marked for Review Next
What will be the output of the following Java program?class mainclass { public static void main(String args[]) { boolean ct1 = true; boolean ct2 = false; if (ct1) System.out.println(ct1); else System.out.println(ct2); } }Options10truefalse
rect answerWhat will be the output of the following Java program?class java { public static void main(String args[]) { int w = 5; int x = 10; first: { second: { third: { if (w == x >> 1) break second; } System.out.println(w); } System.out.println(x); } } }
e correct answerWhat is the output of the following Java program?class Main { public static void main(String args[]) { final int i; i = 20; i = 30; System.out.println(i); }}
What will be the output of the following program?class string_class {public static void main(String args[]){String obj = "hello";String obj1 = "world"; String obj2 = obj;obj2 = " world";System.out.println(obj + " " + obj2); }}
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.