Java Programming Week 9 Module 7
Java Programming Week 9 Module 7
Department of Education
National Capital Region
JAVA PROGRAMMING
Science, Technology, Engineering
and Mathematics (STEM) Strand
Learning Competency:
Creating Java Applications
LESSON 7: JAVA NETBEANS IDE and CREATING THE FIRST JAVA APPLICATION
1
JAVA PROGRAMMING
K TO 12 CURRICULUM
DIVISION OF CITY SCHOOLS – PASIG
DEPARTMENT OF EDUCATION
2
Before starting the module, set aside tasks that might hinder you to enjoy the lesson. You’ll be
given instructions to successfully meet the objectives of this module! Have fun!
1. Read the content and follow the instructions for activities and learning outcomes in
every page of the module
2. You are also strongly encouraged to do hands-on check to make sure that you follow
all instructions as actual hands-on/demonstration of the activity will be required in
the succeeding modules
3. You’ll be provided with activities that require program logic formulation and
demonstration of writing codes.
4. Analyze the concepts and answer the post-test to evaluate how you
perform in every module.
5. Enjoy learning!
Posttest - This measures how much you have learned from the
entire module.
3
Parts of the module:
Specific objectives: This are the list of specific goals to meet after completing each
module.
Pre-test: This will determine students’ prior knowledge on the concepts
included in the course
Brief Introduction: This will give you an overview of the scope and sequence of
discussion in this module.
Technical Terms: Are vocabulary words that specializes in the field of computing.
Activities: Are set of tasks that you need to accomplish in this module.
Remember: This section explains the summary concepts and applications discussed
in every module.
Check your understanding: This section will assess your learning from each lesson
in this module.
Post-test: This will assess how much you learn from each part of the module.
TECHNICAL TERMS
Abstraction
It’s a java concept which means showing the relevant information that is need for
a task.
Encapsulation
For data security purposes, this concept identifies data that is stored within the
classes and is not easily accessible to anyone.
4
Inheritance
The attributes and characteristics of one class can be inherited by another class.
In effect, it takes less time writing codes.
Polymorphism
This means using the same method for different tasks.
In java, we can use the same object or variable in two different places where their
tasks will differ.
Define Loop.
___________________________________________________
___________________________________________________
___________________________________________________
Multiple Choice: Choose the letter of the correct answer that referred to the
statements below.
1. Which of the following Java Netbeans IDE parts displays the tools used for
commonly used tasks?
a. Title bar
b. Menu bar
c. Tool bar
d. Toolbox
5
2. Which of the following Java edition is used when the user wants to create a
mobile application?
a. Java SE
b. Java ME
c. Java EE
d. Java CE
Programming makes life easier. Consider how easy to book a ticket at a travel agency,
shopping and paying your bills at the comfort of your own home. Everything has become
possible because of the development of programming languages including Java.
6
For some basic household electronic devices such as tv, washing machine, air-condition
units and a lot more, Java program has played a part.
They name the language, “Oak” and later change to “Green” then to “Java Coffee” which
was named after the coffee in Indonesia and finally to “Java” in 1995.
There are three (3) editions of Java you can choose from based on your preference.
Java ME (Java Platform Micro Edition):- It has concepts to develop software for
consumer electronic devices means embedded systems, like mobile and electronic level
applications. Java ME was popular for developing mobile gaming applications. This
edition was called micro because these edition programs are embedded in small chips.
The program embedded in the chip is called micro (small).
Java files are converted to bit code format using a compiler and then executed by a java
interpreter.
The whole java code is run on the Java Virtual Machine (JVM) which provides a runtime
environment.
The main concepts of java are methods and classes. A method is a block of code that
performs a task only when it is called. Example: While watching tv, you use a remote to
change channels. Each button on the remote performs a different task. Methods in java
are the same.
A group of methods make a class. Classes are used to organize code just how fruits and
vegetables and other products are divided into different sections in a supermarket
7
Java features:
2. Encapsulation
- makes the java code secure. Data is stored within the classes and it it not easy to access
the data.
3. Inheritance
- the attributes and characteristics of one class can be inherited by another class. It
makes coder take less time to create the code.
4. Polymorphism
--using the same method for different tasks
In java, we can use the same object or variable in two different places where their tasks
will differ.
In java, we use objects and classes related to the real world that makes it easier to read
and understand.
Step 1. Key in jdk download in the search bar and click the hyperlink.
8
Step 2. For windows installation, select Windows, x64 installer
Step 3. Click the file to proceed with the installation. Click Next.
9
Step 5. Java will be installed in your program files by default. If you wish to change the
directory of the installation folder, click the Change button. Otherwise, click Next.
10
Installing Apache Netbeans.
Step 1. Type in java download at the search bar and click the hyperlink.
11
Step 4. Open the downloaded file. Click next to proceed installation
12
Step 5. Tick the checkbox to accept terms and conditions.
Step 6. Set your preferred location where to install Apache Netbeans. Click the next
button.
13
Step 7. To automatically check for updates for installed, the checkbox is ticked by
default. Click the install button.
Step 8. Wait for the installation process until the figure below is displayed. Click finish
and your Apache Netbeans software is ready to use.
14
The Java Integrated Development Environment (IDE)
To familiarize yourself with the Java IDE, follow the following steps.
Step 1. Launch the application by typing Apache Netbeans IDE at the search bar. This
will display options about the program.
Step 2. This will display the start-up page and the default set up for the application
15
Apache Netbeans components and their functions:
2. Menu bar and pull down menus – it consists of all available menus which offer
several options that a user can choose from.
3. Tool bar – It displays icons for most commonly used tasks. It displays the most
frequently used commands.
16
4. Project Explorer Window – It displays the different applications created in
Netbeans which makes it easier for users to navigate them at any time.
5. The Code Editor Window – It serves the working area where the user write
Java codes for application.
17
6. Graphical User Interface (GUI) – It is a workspace where the user can build
GUI in Netbeans. It has two views namely Source view and Design view. Design
view enables you to layout forms by clicking and dragging components into it
while Source view enables you to write your java codes.
18
8. The properties window – It displays possible options to manipulate each
component in Netbeans
Step 1. Click the File Menu. Select New Project in the pull-down or press Ctrl+Shift+N
on your keyboard.
19
Step 2. Select Java Application from the Projects list.
20
Step 4. Notice how the title bar, project name and the codes where set using the
project name you use.
In java programming, each line of code must be inside a class. In the above figure,
note that we name it My_first_java_application. Remember that classes should
start with an uppercase first letter.
21
For now, just remember that every Java program has a class name which must
match the filename, and that every program must contain the main() method.
System.out.println()
Inside the main() method, we can use the println() method to print a line of text to
the screen:
Note: The curly braces {} marks the beginning and the end of a block of code.
System is a built-in Java class that contains useful members, such as out, which is
short for "output". The println() method, short for "print line", is used to print a
value to the screen (or a file).
Don't worry too much about System, out and println(). Just know that you need
them together to print stuff to the screen.
You should also note that each code statement must end with a semicolon (;).
Print()
Output:
22
The print() function does not insert a new line compared to println().
Output:
23
1. Name the parts of Java IDE and define their functions.
2. Compare Java IDE to other programming IDEs (E.g. Visual Basic, Python, etc)
Multiple Choice: Choose the letter of the correct answer that referred to the
statements below.
1. Which of the following Java Netbeans IDE parts displays the tools used for
commonly used tasks?
a. Title bar
b. Menu bar
c. Tool bar
d. Toolbox
24
2. Which of the following Java edition is used when the user wants to create
a mobile application?
a. Java SE
b. Java ME
c. Java EE
d. Java CE
1. C
2. B
3. A
4. C
5. D
25
Note: Answers may vary.
Output:
You don’t have to see the whole staircase, just take the first step.
-Martin Luther
We set goals for ourselves and the only way to achieve them is by taking our first baby
steps. Do you agree with this? Explain your answer.
___________________________________________________________
___________________________________________________________
___________________________________________________________
___________________________________________________________
26
References
27
28
29