🚀 Join 1,200+ candidates currently preparing with PrimerPrep
Java Programming
Accenture Technical PrimermediumJava Programming1. Introduction To Java

Accenture Java Programming Practice Question

What is the output of this program? class selection_statements { 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); } }

Answer options

A
1
B
2
C
4
D
3 Observe the if construct. var 2 is assigned 1. 1 does not equal 5, hence else block will get execute

Correct answer: 2

Explanation

Quick AnswerThe correct answer is 2 because it directly addresses the core logic of Java Programming.

Correct answer: 2.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!