+3 votes
in Class 12 by kratos

Ruby, a class XI student has just started learning java programming. Help her in the following:

(i) Explain her the concept of variable and data type by suitable example.

(ii) Help her in understanding the difference between assignment operator and comparison operator with the help of appropriate example.

1 Answer

+6 votes
by kratos
 
Best answer

(i) Variables are named storage location to store values temporarily which can be changed during program *****.

Data type states the way the values of that type are stored, the operations that can be done on that type and the range for that type.

For example:

int marks;

In the above statement, int is the data type and marks is the name of variable which store values temporarily.

(ii) Assignment operator (=) is used to assign any value in a variable/constant while comparison operator (= =) is used to compare values.

For example:

int marks=90;

In the above statement value 90 is assigned to the variable named marks.

if(marks==40)

jTextField1.setText(“Just Pass”);

In the above if statement, value of marks is being compared with 40.

...