ICSE Class 9 Computer Applications Question 2 of 21

Operators in Java — Question 2

Back to all questions
2
Question

Question 2

What is an assignment operator? Give an example.

Answer

Assignment operator is used to assign the value of an expression to a variable. It has the following syntax:

variable = expression;

For example,

totalMarks = 780;

The above statement assigns the value of 780 to the variable totalMarks. Any previous value stored in totalMarks variable is overwritten by this new value.