Probably because these questions are made up by people who learned their programming in the 70's-90's, who still haven't got their heads around the fact that, for many modern languages, these sorts of things simply aren't important.
If this was an interview for a perl job, a question like that would generate derisive laughter - and rightly so - so why do people think it's important for Java?
And finally, while it's good to have a general idea of the heap/stack landscape, you'll almost never actually care about it when you're developing with Java. About the only time it would come into play is if you're actually writing your own JVM implementation, or if you're working on a specialized or limited-memory JVM, or if you're doing hardcore profiling for memory or performance problems.
Sebastian Janisch wrote:If the user input is 5.0, is it okay to display it as 5 ??
In that case just convert everyting to double, sort it and when displaying it as text again check if the number is a whole number and if that is the case strip the .0 to convert 5.0 back to 5