Answers Graded A+
What is the purpose of the `Scanner` class in Java?
✔✔ To read user input from different input sources like the keyboard.
How do you declare a constant variable in Java?
✔✔ By using the `final` keyword before the variable declaration.
What will happen if you try to divide an integer by zero in Java?
✔✔ It will throw an `ArithmeticException`.
How do you concatenate two strings in Java?
✔✔ By using the `+` operator or the `concat()` method.
What keyword is used to define a method in Java?
✔✔ The `void` or any return type followed by a method name.
1
, What does the `modulus` operator (%) return?
✔✔ The remainder of a division operation.
What is the default value of an integer variable in Java if not initialized?
✔✔ 0
How do you take an integer input from the user in Java?
✔✔ By using `Scanner` and calling `nextInt()`.
What is the purpose of an `if` statement in Java?
✔✔ To execute a block of code only if a specified condition is true.
How do you create a single-line comment in Java?
✔✔ By using `//` before the comment text.
How do you create a multi-line comment in Java?
✔✔ By enclosing the comment text between `/*` and `*/`.
2