Member-only story

Java tricky interview questions

Mukul Jha
3 min readSep 27, 2022

--

Attempt to solve these questions. If you find them challenging, try debugging the code snippets to find the answers.

Q1. What is the output of the given code snippet?

int i =15;
int j = i++ + --i;
System.out.println(j);

a. 30
b. 29
c. 31
d. 32

Answer: a

Q2. What is the output of the given code snippet?

int i = 15;
int j = ++i - --i + i;
System.out.println(j);

a. 17
b. 15
c. 16
d. 14

Answer: c

Q3. What is the output of the given code snippet?

int i = 15;
int j = i++ + ++i;
System.out.println(j);

a. 33
b. 30
c. 32
d. 31

Answer: c

Q4. What is the output of the given code snippet?

int i = 15;
int j = i++ - --i + i + i++ +i;
System.out.println(j);

a. 47
b. 75
c. 46
d. 45
e. None of these

Answer: c

Q5. What is the output of the given code snippet?

int i = 15;

--

--

No responses yet