Programming Java: Grade 11
Programming Java: Grade 11
Programming Java: Grade 11
Region V
Division of City Schools
Naga City
DON LEON Q. MERCADO HIGH SCHOOL
PROGRAMMING
JAVA
GRADE 11
Quarter 4 Week 1 Module 1
Learning Competency:
INTRODUCTION TO PROGRAMMING
LESSON 1
FOUR PROGRAMMING FUNDAMENTALS
INTRODUCTION TO
PROGRAMMING
SENIOR HIGH SCHOOL
GRADE 11
Before starting the module, I want you to set aside other tasks that will disturb you while
enjoying the lessons. Read the simple instructions below to successfully enjoy the
objectives of this kit. Have fun!
1. Follow carefully all the contents and instructions indicated in every page of this module
and follow the given instructions for each of the given learning outcome/s.
2. As you read, you can also do the hands-on to check if you were able to follow the
basic programming procedure.
3. Demonstrate what you have learned by doing what the Activity required you to do so.
4. Analyze conceptually the posttest and apply what you have learned.
5. Enjoy studying!
PARTS OF TH MODULE
Before starting the module, I want you to set aside other tasks that will disturb you while
enjoying the lessons. Read the simple instructions below to successfully enjoy the
objectives of this kit. Have fun!
1. Follow carefully all the contents and instructions indicated in every page of this module
and follow the given instructions for each of the given learning outcome/s.
2. As you read, you can also do the hands-on to check if you were able to follow the
basic programming procedure.
3. Demonstrate what you have learned by doing what the Activity required you to do so.
4. Analyze conceptually the posttest and apply what you have learned.
5. Enjoy studying!
• Expectations - These are what you will be able to know after completing the lessons in
the module..
• Technical terms - A word that has a specific meaning within a specific field of
expertise.
• Looking Back to your Lesson - This section will measure what learnings and skills did
you understand from the previous lesson.
• Brief Introduction- This section will give you an overview of the lesson.
• Activities - This is a set of activities you will perform with a partner.
• Remember - This section summarizes the concepts and applications of the lessons.
• Check your Understanding- It will verify how you learned from the lesson.
1
INTRODUCTION TO PROGRAMMING
, LESSON 1
OVERVIEW OF COMPUTER PROGRAMMING
EXPECTATIONS:
Develop a simple valid Java program using the consepts learned in this
chapter
TECHNICAL TERMS:
indicates the name of the class which is Hello. In Java, all code should be placed
insidea class declaration. We do this by using the class keyword. In addition, the
class uses anaccess specifier public, which indicates that our class in accessible to
other classes from other packages (packages are a collection of classes). We will be
covering packages and access specifiers later.
The next line which contains a curly brace { indicates the start of a block. In this
code,we placed the curly brace at the next line after the class declaration, however,
we can also place this next to the first line of our code. So, we could actually write
our code as:
The next three lines indicates a Java comment. A comment is something used to
document a part of a code. It is not part of the program itself, but used for
documentation purposes. It is good programming practice to add comments to your
code.
/**
* My first java program
*/
A comment is indicated by the delimiters “/*” and “*/”. Anything within these
delimiters are ignored by the Java compiler, and are treated as comments.
The next line,
indicates the name of one method in Hello which is the main method. The main
method is the starting point of a Java program. All programs except Applets written
in Java start with the main method. Make sure to follow the exact signature.
The next line is also a Java comment,
Now, we learned two ways of creating comments. The first one is by placing the
comment inside /* and */, and the other one is by writing // at the start of the
comment.
System.out.println("Hello world!");
prints the text “Hello World!” on screen. The command System.out.println(), prints
the text enclosed by quotation on the screen.
The last two lines which contains the two curly braces is used to close the main
method
and class respectively.
Java supports three types of comments: C++-style single line comments, C-style
multiline comments and special javadoc comments.
C-style comments or also called multiline comments starts with a /* and ends with
a */.
All text in between the two delimeters are treated as comments. Unlike C++ style
comments, it can span multiple lines. For example,
/* this is an exmaple of a
C style or multiline comments */
Special Javadoc comments are used for generating an HTML documentation for
your Java programs. You can create javadoc comments by starting the line with /**
and ending it with */. Like C-style comments, it can also span lines. It can also
contain certain tags to add more information to your comments. For example,
/**
This is an example of special java doc comments used for \n
generating an html documentation. It uses tags like:
@author Florence Balagtas
@version 1.2
*/
System.out.println(“Hello world”);
A block is one or more statements bounded by an opening and closing curly braces
that groups the statements as one unit. Block statements can be nested
indefinitely. Any amount of white space is allowed. An example of a block is,
Java Identifiers
Identifiers are tokens that represent names of variables, methods, classes, etc.
Examples of identifiers are: Hello, main, System, out.
Java identifiers are case-sensitive. This means that the identifier: Hello is not the
same as hello. Identifiers must begin with either a letter, an underscore “_”, or a
dollar sign “$”. Letters may be lower or upper case. Subsequent characters may
use numbers 0 to 9.
Identifiers cannot use Java keywords like class, public, void, etc. We will discuss
more about Java keywords later.
Java Keywords
Keywords are predefined identifiers reserved by Java for a specific purpose. You
cannot use keywords as names for your variables, classes, methods …etc. Here is a
list of the Java Keywords.
Java Literals
Literals are tokens that do not change or are constant. The different types of literals
in Java are: Integer Literals, Floating-Point Literals, Boolean Literals, Character
Literals and String Literals.
Integer Literals
Integer literals come in different formats: decimal (base 10), hexadecimal (base
16),and octal (base 8). In using integer literals in our program, we have to follow
some special notations.
For example, consider the number 12. It's decimal representation is 12, while in
hexadecimal, it is 0xC, and in octal, it is equivalent to 014.
Integer literals default to the data type int. An int is a signed 32-bit value. In some
cases, you may wish to force integer literal to the data type long by appending the
“l” or “L” character. A long is a signed 64-bit value. We will cover more on data
types later.
Floating-Point Literals
Floating point literals default to the data type double which is a 64-bit value. To
use a smaller precision (32-bit) float, just append the “f” or “F” character.
Boolean Literals
Character Literals
To use a character literal, enclose the character in single quote delimiters. For
example,
the letter a, is represented as „a‟.
To use special characters such as a newline character, a backslash is used followed
By the character code. For example, „\n‟ for the newline character, „\r‟ for the
carriage return, „\b‟ for backspace.
String Literals
String literals represent multiple characters and are enclosed by double quotes. An
example of a string literal is, “Hello World”.
ACTIVITIES
Direction: Write True if the statement is correct and False if its not correct.
REFERENCES:
https://sielearning.tafensw.edu.au/toolboxes/Database_Administration/software/content/pro
grammingconstructs/control_structures.htm
https://study.com/academy/lesson/what-is-an-algorithm-in-programming-definition-examples-
analysis.html
Java-student-Manual-Programming
PREPARED BY:
HAZEL B. FRANCE
Teacher