Grokking Java Interview Questions
Vote

0% completed

​

Predict the Output: Strings and Wrappers

A short program can look obvious and still print something unexpected. The cause is usually one rule of the language that the source code does not show: a type that the compiler chose, a cast that it added, or a value that was read earlier than expected.

Each of the six programs below depends on one such rule about strings, wrapper classes, or operators. Write down every line before you press Run, and then compare your answer with the explanation.

Program 1: Adding Characters

This program uses + on char values, on strings, and on both together.

<details><summary>Show answer</summary>

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content