Asked by christopher Neville on Jun 10, 2024

verifed

Verified

Given
Char ch;
Int num;
Double pay; Which of the following assignment statements are valid?
(i) ch = ' * ' ;
(ii) pay = num * pay;
(iii) rate * 40 = pay;

A) Only (i) is valid
B) (i) and (ii) are valid
C) (ii) and (iii) are valid
D) (i) and (iii) are valid

Assignment Statements

Instructions that assign values to variables in programming.

  • Acquire knowledge on the variable assignment process within Java, including aspects of variable declaration and modification.
  • Comprehend the concept of type casting and analyze expressions that involve various data types.
verifed

Verified Answer

MG
Mintu GogoiJun 16, 2024
Final Answer :
B
Explanation :
(i) is valid because it assigns a character literal to a char variable. (ii) is valid because it assigns the result of multiplying an int and a double (which results in a double) to a double variable. (iii) is not valid because the left side of an assignment must be a variable, not an expression.