TUNASAN NATIONAL HIGH SCHOOL
SDO - Muntinlupa City
ROWELL L. MARQUINA
Senior High School Teacher
TUNASAN NATIONAL HIGH SCHOOL
Lesson 3 - Java Programming
LEARNING OBJECTIVES:
At the end of the session, you will be able to:
1. differentiate print and println from
one another;
2. display text on screen using print and
println;
3. discuss what is a comment in Java
and what it is used in a program; and
4. demonstrate how to display
comments on a Java program;
One of the most basic competencies in Java
programming is how to instruct the program to
display text on the screen.
Java offers two ways of displaying text output on the
screen using the print, and println methods.
DISPLAYING TEXT ON SCREEN
The print method refers to the Java statement that
instructs the program to display text in a single line.
PRINT vs PRINTLN METHOD
The println method on the other hand is used to
display text in separate lines.
PRINT vs PRINTLN METHOD
As we have discussed earlier, the print method is used
to display text in a single line.
Even if you code the lines separately using print
method, the texts will still appear in a single line.
PRINT vs PRINTLN METHOD
The println method on the other hand is used to
display text in separate lines.
What happens in the code is that
after the first line of text is
displayed it will bring the cursor to
the next line before displaying the
second line of text and so forth.
System.out refers to the Java object that details where it will
display the output of the program.
ANATOMY OF THE PRINT METHOD
print refers to the method that instructs the program to
display the text in a single line.
(“Have a wonderful day!”) is the text that will be displayed
on the screen.
; is referred to as a separator which signifies the end
of the line code.
PRACTICE TEST 1:
Create a simple program which
will display the numbers 1-5 in a
single line. Each number must be
displayed using individual print
methods.
PRACTICE TEST 2:
Using println, create a simple
program which will display the
following information:
▪ Name
▪ Date of Birth
▪ Name of Father
▪ Name of Mother
PRACTICE TEST 3:
On a piece of paper, write the
expected output of the source
code below:
WHAT ARE COMMENTS?
Comments are non-executable Java statements that
are used by programmers to place notes, descriptions,
or explanations on their program.
It is also referred to as inline documentation because
it is used to document and provide explanations
about specific parts of the program.
This is an example of a comment in Java.
WHAT ARE COMMENTS?
Since comments are non-executable statements,
they do not have any effect on the program.
SINGLE-LINE COMMENTS
There are two ways of writing comments in Java. The
one you are seeing below is called a single-line
comment which is used for writing short narrative or
explanations in a program. It is characterized by two
forward slashes ( // ) at the beginning of the
comment.
This is a single-line comment in Java.
MULTI-LINE COMMENTS
The other method is by writing a multi-line comment
which is for writing complex and details
documentations on the program. It is a block
statements that starts with forward slash then asterisk
(/*) and ends with a (*/) asterisk and forward slash.
This is a multi-line comment in Java.
PRACTICE TEST 4:
Using println, create a simple program
which will display the required
information below. Include comments
that tells something about the
information you have provided.
▪ Nickname
▪ Childhood Hero
▪ Favorite Color
▪ Dream Profession
DISPLAYING TEXT ON SCREEN
AND WRITING COMMENTS
MR. ROWELL L. MARQUINA
Tunasan National High School
Senior High School Department
Email Address:
rowell.marquina001@deped.gov.ph
sirrowellmarquina@gmail.com
rmarquina@mitis.edu.ph

Lesson 3 - Displaying Text on Screen.pdf

  • 1.
    TUNASAN NATIONAL HIGHSCHOOL SDO - Muntinlupa City ROWELL L. MARQUINA Senior High School Teacher TUNASAN NATIONAL HIGH SCHOOL Lesson 3 - Java Programming
  • 2.
    LEARNING OBJECTIVES: At theend of the session, you will be able to: 1. differentiate print and println from one another; 2. display text on screen using print and println; 3. discuss what is a comment in Java and what it is used in a program; and 4. demonstrate how to display comments on a Java program;
  • 4.
    One of themost basic competencies in Java programming is how to instruct the program to display text on the screen. Java offers two ways of displaying text output on the screen using the print, and println methods. DISPLAYING TEXT ON SCREEN
  • 5.
    The print methodrefers to the Java statement that instructs the program to display text in a single line. PRINT vs PRINTLN METHOD The println method on the other hand is used to display text in separate lines.
  • 6.
    PRINT vs PRINTLNMETHOD As we have discussed earlier, the print method is used to display text in a single line. Even if you code the lines separately using print method, the texts will still appear in a single line.
  • 7.
    PRINT vs PRINTLNMETHOD The println method on the other hand is used to display text in separate lines. What happens in the code is that after the first line of text is displayed it will bring the cursor to the next line before displaying the second line of text and so forth.
  • 8.
    System.out refers tothe Java object that details where it will display the output of the program. ANATOMY OF THE PRINT METHOD print refers to the method that instructs the program to display the text in a single line. (“Have a wonderful day!”) is the text that will be displayed on the screen. ; is referred to as a separator which signifies the end of the line code.
  • 9.
    PRACTICE TEST 1: Createa simple program which will display the numbers 1-5 in a single line. Each number must be displayed using individual print methods.
  • 10.
    PRACTICE TEST 2: Usingprintln, create a simple program which will display the following information: ▪ Name ▪ Date of Birth ▪ Name of Father ▪ Name of Mother
  • 11.
    PRACTICE TEST 3: Ona piece of paper, write the expected output of the source code below:
  • 13.
    WHAT ARE COMMENTS? Commentsare non-executable Java statements that are used by programmers to place notes, descriptions, or explanations on their program. It is also referred to as inline documentation because it is used to document and provide explanations about specific parts of the program. This is an example of a comment in Java.
  • 14.
    WHAT ARE COMMENTS? Sincecomments are non-executable statements, they do not have any effect on the program.
  • 15.
    SINGLE-LINE COMMENTS There aretwo ways of writing comments in Java. The one you are seeing below is called a single-line comment which is used for writing short narrative or explanations in a program. It is characterized by two forward slashes ( // ) at the beginning of the comment. This is a single-line comment in Java.
  • 16.
    MULTI-LINE COMMENTS The othermethod is by writing a multi-line comment which is for writing complex and details documentations on the program. It is a block statements that starts with forward slash then asterisk (/*) and ends with a (*/) asterisk and forward slash. This is a multi-line comment in Java.
  • 17.
    PRACTICE TEST 4: Usingprintln, create a simple program which will display the required information below. Include comments that tells something about the information you have provided. ▪ Nickname ▪ Childhood Hero ▪ Favorite Color ▪ Dream Profession
  • 18.
    DISPLAYING TEXT ONSCREEN AND WRITING COMMENTS MR. ROWELL L. MARQUINA Tunasan National High School Senior High School Department Email Address: rowell.marquina001@deped.gov.ph sirrowellmarquina@gmail.com rmarquina@mitis.edu.ph