0% found this document useful (0 votes)
10 views

Programming 3 - Module 5

This document is a lesson on declaring multiple variables and assignment operators in Java from Cieverose College. It discusses declaring multiple variables of the same type using a comma-separated list. It also covers basic assignment operators like =, +=, and -= and provides examples of how to use each one to assign values to variables. There is a post-test with multiple choice questions to assess understanding of declaring variables and assignment operators.

Uploaded by

helios3279
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Programming 3 - Module 5

This document is a lesson on declaring multiple variables and assignment operators in Java from Cieverose College. It discusses declaring multiple variables of the same type using a comma-separated list. It also covers basic assignment operators like =, +=, and -= and provides examples of how to use each one to assign values to variables. There is a post-test with multiple choice questions to assess understanding of declaring variables and assignment operators.

Uploaded by

helios3279
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CIEVEROSE COLLEGE, INC.

1644 ILANG-ILANG ST., CAMARIN CALOOCAN CITY

Programming 3
LESSON 5
(Week 5)
Understanding declaring multiple variables and assignment operators
5.1 Declaring many variables
5.2 Assignment operators

For this lesson, you are expected to:


* Importance of declaring many variables with the same data type.
* Understanding the assignment operators.

Encircle the correct answer/letter.

1. Method to reads a short value from the user


a. nextLine() b. nextLong() c. nextShort() d. nextInt()

2. Method to reads a float value from the user


a. nextBoolean() b. nextFloat() c. nextDouble() d. nextByte()

3. Method to reads a string value from the user


a. nextShort() b. nextLong() c. nextInt() d. nextLine()

4. Method to reads a byte value from the user


a. nextByte() b. nextBoolean() c. nextDouble() d. nextFloat()
CIEVEROSE COLLEGE, INC.
Ilang-ilang St. Camarin Programming 3 – Java Jefferson Guevarra
Caloocan City Lesson 5 - Week 5 Teacher
Page |1
CIEVEROSE COLLEGE, INC.
1644 ILANG-ILANG ST., CAMARIN CALOOCAN CITY

5. What is the java class to get the user input?


a. scan b. scanner c. int d. boolean

Lessons

Lesson 5: Understanding declaring multiple variables and assignment operators


5.1: Declaring many variables
- To declare more than one variable of the same type, use a comma-separated list:

5.2: Assignment Operators


Assignment operators are used to assign values to variables.
In the example below, we use the assignment operator (=) to assign the value 10 to a variable called a:

CIEVEROSE COLLEGE, INC.


Ilang-ilang St. Camarin Programming 3 – Java Jefferson Guevarra
Caloocan City Lesson 5 - Week 5 Teacher
Page |2
CIEVEROSE COLLEGE, INC.
1644 ILANG-ILANG ST., CAMARIN CALOOCAN CITY

A list of basic assignment operators:

Example of =, it is the same with x = 5

Example of +=, it is the same with x = x + 3

CIEVEROSE COLLEGE, INC.


Ilang-ilang St. Camarin Programming 3 – Java Jefferson Guevarra
Caloocan City Lesson 5 - Week 5 Teacher
Page |3
CIEVEROSE COLLEGE, INC.
1644 ILANG-ILANG ST., CAMARIN CALOOCAN CITY

Example of - =, it is the same with x = x – 3

Continuation of other assignment operators will be on Lesson 6.

Post test

Activity#1:
Encircle the correct answer/letter.
1. Assignment operator to assign a value in a variable?
a. = b. += c. -= d. *=

2. What assignment operator you should use that the same as x = x - 3 ?


a. /= b. -= c. += d. *=

3. What assignment operator you should use that the same as x = x + 3 ?


a. /= b. -= c. += d. *=

4. To declare more than one variable of the same type, you must use
a. comma b. + c. concatenation d. semicolon

5. Is it possible to declare many variables in one data type?


a. true/yes b. false/no

CIEVEROSE COLLEGE, INC.


Ilang-ilang St. Camarin Programming 3 – Java Jefferson Guevarra
Caloocan City Lesson 5 - Week 5 Teacher
Page |4

You might also like