What is the output of java codes snippet
short k=1;
k+=2;
System.out.print(k);
Answers
Answered by
3
Answer:
the answer is 3
Explanation:
initial value of k is 1
value of k+=2 is 3
hence new value of k is 3
Answered by
0
Answer:
The output will be 3
Explanation:
According to the question,
'short' is a keyword that stores the value 1 (here)
k + = 2 has a unary operator .
Therefore, the statement means k = k + 2
Method used:
Dry run - Run the program using the input
k = 1
k+ = 2
=> k = k + 2
= 1 + 2
= 3
Since the final value of k is 3 , the output will be 3
Similar questions
Environmental Sciences,
3 months ago
Math,
7 months ago
Math,
7 months ago
Business Studies,
11 months ago
Biology,
11 months ago