KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

What will be the output of the following code?

int k=5,j=9;
k+= k++ - ++j + k;
System.out.println("k="+k);
System.out.println("j="+j);

Java

Java Operators

ICSE

214 Likes

Answer

k=6
j=10

Working

    k+= k++ - ++j + k
⇒ k = k + (k++ - ++j + k)
⇒ k = 5 + (5 - 10 + 6)
⇒ k = 5 + 1
⇒ k = 6

Answered By

117 Likes