Java Basic Questions Leetcode Problem