Programming 3 - Module 2
Programming 3 - Module 2
Programming 3
Java
STUDENT
LEARNING
MODULE
Programming 3
LESSON 2
(Week 2)
Understanding Comments, Variables, and Data Types
2.1 Understanding Comments
2.2 Learning Variable
2.3 Data types and its function
2.4 Running simple program with data type, variable, and comment
To start with this module, you are advised to follow these simple instructions to
assure learning.
1. Look for a good place to study to. It should have clear surroundings, proper ventilation,
free from different noise, and make sure the lights are on.
2. Prepare all the learning tools and materials.
3. Answer the pre-test based on your retained learning.
4. Read and analyze the content of the module.
5. Takedown notes so that you will remember all the important details.
6. Finish all the activities in the module. Enjoy every moment of doing it.
7. Let the facilitator/guardian evaluate your work.
8. Review and prepare for the post-test.
9. Apply the skills you have learned after doing all the activities.
JUMBLED LETTERS
Directions: Read each statement and rearrange the jumbled letters to form a word
that is being described in the statement. Write your answers on the line provided.
1: Annotation used to explain C++ code however it doesn't effect on the behavior of the code.
mctenom = _________________________________
Lessons
// - (line comment) All lines beginning with two slash signs (//) are considered comment and
any text between // and the end of the line is ignored by the compiler (will not be executed).
/* */ - (block comment) Discards everything between the /* characters and the first appearance
of the */ characters, with the possibility of including more than one line.
- To create a variable, you must specify the data type and assign it a value:
Very important: The java language is a "case sensitive" language. That means that an
identifier written in capital letters is not equivalent to another one with the same name but
written in small letters. Thus, for example, the RESULT variable is not the same as the result
variable or the Result variable. These are three different variable identifiers.
The data type specifies the size and type of information the variable will store:
Example:
OUTPUT:
OUTPUT:
OUTPUT:
Post test
Activity#1:
- Create a program that you will use “comment” describing what data type you are
using and use “double” for adding two variables with a value of 5 and 5.5 and the
result should be like this below.
OUTPUT:
Activity#2:
- Write the correct answer.
1. What is the code for the single line comment?
2. What is the code for the multiline comment?
3. What data type stores true or false values?
4. What data type stores a single character/letter/number or ASCII values?
5. What data type stores whole number without decimals?