Hetero interview question

Basic java