Assess your foundational understanding of Java programming concepts relevant to backend development. Ideal for beginners aiming to strengthen their Java fundamentals.
Which keyword is used to declare a variable that holds whole numbers in Java, such as 10 or -5?
Explanation: The 'int' keyword declares a variable for whole numbers. 'bool' is not a valid keyword in Java; Java uses 'boolean' for true/false values. 'char' is meant for single characters. 'float' is for decimal numbers, not integers.
What is the correct signature for the main method that serves as the starting point of a Java application?
Explanation: 'public static void main(String[] args)' is the required entry point for Java applications. The others either have incorrect order, missing 'static', wrong parameter types, or lack required array syntax.
How do you write a single-line comment in Java to describe your code?
Explanation: // begins a single-line comment in Java. '#' is used in languages like Python, '--' is used in SQL, and '<!-- -->' is for HTML comments.
Which code correctly creates a new object from the 'Car' class in Java?
Explanation: The correct object creation syntax is 'Car myCar = new Car();'. The other options either miss required syntax like 'new', parentheses, or use an invalid order of elements.
Which of these is a valid variable name in Java?
Explanation: 'totalAmount' is a valid variable name as it starts with a letter and has no forbidden characters. '2value' starts with a digit, which is not allowed. 'class' is a reserved keyword, and 'total-amount' includes a hyphen, which is invalid.