Java Programming Logical Questions