What is a string literal in Java?
A string of characters represented by enclosing it in double quotes.
What method is used to print a character string to the console in Java?
The println method.
How does the print method differ from the println method?
The print method does not advance to the next line after printing.
What operator is used for string concatenation in Java?
The + operator.
What are some examples of Java escape sequences?
\b (backspace), \t (tab), \n (newline), " (double quote).
What is a variable in Java?
A name for a location in memory that can hold a value.
What does the assignment operator do in Java?
It changes the value of a variable.
What keyword is used to declare a constant in Java?
The final modifier.
What are the eight primitive data types in Java?
byte, short, int, long, float, double, char, boolean.
What is the difference between widening and narrowing conversions?
Widening conversions go from a smaller to a larger data type, while narrowing conversions go from a larger to a smaller type and can lose information.
What class in Java is used for reading user input?
The Scanner class.
What does the nextLine method of the Scanner class do?
It reads all input until the end of the line as a character string.
What is the purpose of the conversion operators in Java?
To convert data from one type to another.
How are arithmetic expressions evaluated in terms of operator precedence?
Multiplication, division, and remainder are evaluated before addition and subtraction.
What happens if you use the / operator with two integers in Java?
The result will be an integer with the fractional part discarded.
How can you avoid ambiguity in operator precedence in an expression?
By using parentheses to explicitly define the order of evaluation.
What is the result of using the increment operator on a variable?
It adds one to the variable's current value.
What is the significance of a boolean value in Java?
It represents a true or false condition.
What does the Scanner class require to be imported to use it in a program?
The java.util class library.
How does the initialization of a variable work in Java?
A variable can be given an initial value at the time of declaration.
When is the result of an expression in Java evaluated?
The expression on the right side of an assignment operator is evaluated before storing the result in the variable on the left.