What is the purpose of the nextInt() function in the Scanner class?
The nextInt() function is used to take integer input.
How can we print the input obtained from nextInt()?
We can print the input by assigning a variable to it.
What is the output when the variable is printed for the first time?
The initial value of the variable is printed.
What happens to the value of the variable after it is printed for the second
time?
The value of the variable is decremented by 1.
How many times is the value 2 printed?
The value 2 is printed three times.
What are the comparison operators used in Java?
The comparison operators used in Java are greater than (>), less than (<), greater than or
equal to (>=), less than or equal to (<=), equal to (==), and not equal to (!=).
How are conditional statements used in Java?
Conditional statements are used to test if a certain condition is satisfied or not.
, What are logical operators used for?
Logical operators are used to analyse multiple statements or evaluate logic.
What are logical operators used for in Java?
Logical operators are used to check if a condition is true or false.
What is the 'and' operator in Java?
The 'and' operator requires both conditions to be true to output the result.
How is the 'or' operator represented in Java?
The 'or' operator is represented by two pipes or straight lines on the keyboard.
What does the negation operator do?
The negation operator, represented by an exclamation mark, negates a true condition to false
and a false condition to true.
What happens if the cash is less than 10?
If the cash is less than 10, the program will print 'cannot buy anything'.
What happens if we have more than 50 rupees?
If we have more than 50 rupees, we can buy both a pen and a pencil.
What is the switch statement used for in Java?
The switch statement is used to check multiple conditions based on a variable's value.