0% found this document useful (0 votes)
11 views58 pages

Java Programming Practicum Report

This practicum report discusses the Java programming language practicum which includes an introduction to Java and NetBeans, operators, classes, objects, methods, looping and branching structures, as well as object-oriented programming. This report also presents the results of experiments from each practicum module and analyzes the results.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views58 pages

Java Programming Practicum Report

This practicum report discusses the Java programming language practicum which includes an introduction to Java and NetBeans, operators, classes, objects, methods, looping and branching structures, as well as object-oriented programming. This report also presents the results of experiments from each practicum module and analyzes the results.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICAL REPORT Class

TI - 5D SORE
JAVA PROGRAMMING LANGUAGE

NUMBER DATE SIGNATURE


NAME OF PRACTITIONER
STUDENT GATHER PRACTITIONER

FIRMANSYAH 1214370514 05 - 01 - 2015

DATE SIGNATURE
NAME OF ASSESSOR VALUE
CORRECTION LECTURER

INDRI SULISTIANINGSIH [Link]

Panca Budi Development University

Faculty of Engineering

Computer Systems Engineering

Medan

2015
FOREWORD

In the name of Allah, the Most Gracious, the Most Merciful.

Peace be upon you.

Praise and gratitude I raise to the presence of Allah SWT, who has bestowed various blessings.

rahmat dan Karunia-Nya sehingga penulis masih diberi kesempatan untuk meyelesaikan tugas
laporan praktikum ini guna memenuhi tugas mata kuliah Bahasa Pemrograman Java ini.
Blessings and peace may always be bestowed upon our Prophet Muhammad SAW.
Family, Friends, and his loyal followers who continue to uphold and follow his sunnah.
until the end of time.
In preparing this practical report, the author faced several obstacles.
However, with great patience and especially with the help of Allah SWT, the report...
this internship can be completed, but the author realizes there are still many shortcomings and far
from perfection, therefore constructive suggestions and critiques from the supervising lecturer of the course

This lecture is very much hoped for by the author for improvement in the future. Hopefully, the report

this internship can be beneficial and useful for students, especially for myself
Personally, I thank you for your attention.

Binjai, 05 - 01 - 2015
Compiler :

NAMA : FIRMANSYAH
NPM : 1214370514

i
TABLE OF CONTENTS

FOREWORD... I

TABLE OF CONTENTS............................................................................................................................ ii-iii

CHAPTER I: Introduction

a. General 1

b. Background 2

c. Objectives of the Practicum 2

CHAPTER II: Theoretical Foundations of the Java Programming Language

a. Introduction to Java and NetBeans 3

b. Operator 12

c. Class, Object and Method 17

d. Looping and Branching Structure 18

e. Object-Oriented Programming 20

CHAPTER III: Experimental / Practical Results

a. Internship Module 2 25

b. Internship Module 3 27

c. Internship Module 4 29

d. Internship Module 5 32

e. Internship Module 6 37

f. Internship Module 7 41

g. Internship Module 8 45

ii
CHAPTER IV: ANALYSIS OF EXPERIMENT RESULTS

a. Analysis of Practical Work Module 2 50

b. Analysis of Practicum Module 3 50

c. Practice Analysis Module 4 50

d. Practical Analysis Module 5 51

e. Module 6 Practicum Analysis 51

f. Analysis of Practicum Module 7 52

g. Analysis of Practicum Module 8 52

CHAPTER V: CONCLUSION 53

REFERENCE LIST 54

iii
Chapter I Introduction.

a. General
Language Java programming initially specifically for application

internet-based, but now Java applications can be used for not

only web-based but has already expanded from desktop to mobile applications

using it. Java is portable, meaning it can run on various platforms, including Windows,

Linux, Unix, MacOS, or SymbianOS (mobile). The key to this portability is the output.

Java compilation is not an executable file but in the form of bytecode. It is this bytecode that

will be executed by the JRE (Java Runtime Environment) called JVM (Java Virtual Machine)

Machine) and has been installed on every operating system that will be used, so the JVM

is an interpreter for bytecode.

Actually, the execution of an interpreter is slower compared to

The compilation of executables, then Sun provides the HotSpot technology that supplies a JIT compiler.

(Just In-Time) for bytecode and becoming part of the JVM to compile bytecode

becoming executable code in real-time, thus running Java applications faster.

Java language was first conceived by James Gosling, Patrick Naughton, Chris

Warth, Ed Frank, and Mike Sheridan at Sun Microsystems in 1991, with the name of the language

the program 'Oak'. In 1995, they visited a local coffee café and changed

it has been called 'Java' until now.

Java is directly related to C and C++, because Java

its syntax is derived from C and its objects are adapted from C++, so Java has the characteristic

case sensitive (distinguishing between uppercase and lowercase letters).

1
b. Background

Along with the development of time and technology, humans who live

They desire facilities that are all fast and instant. It cannot be denied that

The role of IT in life has a significant impact on large industries worldwide.

the world. One of the programming languages that is often used to create and

developing outstanding applications using the Java programming language.

Java is one of the programming languages that has a complete Class.

with a series of advantages it contains. With application program API (Application

Programming Interface) specifically developed as a communication intermediary

among the components of the software. Java is used to create and

developing applications that support and facilitate human work.

With the rapid advancement of technology, there is also a need for

superior human resources in the context of that development.

This report is prepared with that background, the author intends to study

the Java programming language from the most basic by creating a visual application program

simple. By using the Java programming language, which has more advantages

compared to its weaknesses.

c. The Purpose of the Practicum

The purpose and objectives of preparing this report are as follows:


1. Learning the basics of the Java programming language

2. Training tools for making simple application programs

Deepening all components present in Java

4. Completing the task for the Java Programming course Semester V

2
CHAPTER II Theoretical Basis on the Java Programming Language

a. Introduction to Java and NetBeans

Java

Java is a technology in the world of computer software, which is

a programming language, and at the same time a platform. As a language

programming, Java is known as a high-level programming language. Java is easy

studied, especially for programmers who are familiar with C/C++. Java is a

object-oriented programming language which is a programming paradigm

future. As a programming language, Java is designed to be reliable and secure.

Java is also designed to run on all platforms, and is also designed for

producing applications with the best performance, such as applications

Oracle 8i/9i database core is built using programming language

Java. While Java has a neutral architecture, because the Java Compiler that

used to compile Java program code designed to generate

code that is neutral to all hardware architectures.

As a platform, Java consists of two main parts, namely:

1. Java Virtual Machine (JVM)

2. Java Application Programming Interface (Java API)

Sun divides Java architecture into three parts, namely:

J2EE (Java 2 Enterprise Edition )

2. J2SE (Java 2 Second Edition)


)

3. J2ME (Java 2 Micro Edition)


)

3
1. J2EE (Java 2 Enterprise Edition)

J2EE is a group of several APIs (Application Programming Interfaces) )

dari Java dan teknologi selain Java. J2EE dirancang untuk membuat aplikasi yang rumit.

J2EE is often considered as middleware or technology that runs on the server,

but in fact J2EE is not limited to that. In fact, J2EE also

encompasses technology that can be used at all layers of a system

information.

The J2EE implementation provides the basic classes and APIs from Java that

supporting the development and routine standards for both client and server applications,

including applications that run in web browsers. for web-based applications, applications

a distributed system with a variety of clients with high complexity.

2. J2SE (Java 2 Standard Edition)

The application created and developed by the author in this writing

using the Java 2 Standard Edition-based programming language (more commonly known as

with J2SE). In this section, the author will explain the basics of J2SE, including

Introduction to J2SE and its components. Here is the explanation:

J2SE or Java 2 Standard Edition is the Java programming language for

desktop application that is object-oriented programming. In J2SE, it consists of

two products released to assist in creating applications without

depending on the platform used, namely:

4
Java SE Runtime Environment (JRE)

Java Runtime Environment (JRE) provides libraries, Java Virtual

Machine (JVM), and other components to run applets and applications that

ditulis dengan bahasa pemrograman Java. Selain itu, terdapat dua buah

the key technology that is part of the JRE is: d Plugin, which

enables running applets in popular browsers and Java Web Start,

that spreads independent applications through the network. JRE does not contain

utility such as compiler and debugger for developing applet and

application.

2. Java Development Kit (JDK)

The Java Development Kit (JDK) is software used

for managing and building various Java applications. JDK is

superset of JRE, contains everything in JRE added

compiler and debugger needed to develop applets and

application.

The Java programming language provides standard libraries that have been ...

compiled can be used directly in the implementation of making a

application. In the library, there are various types of classes that can be used and have been

grouped into package . The packages available in J2SE will

described in the table below:

5
Table 2.1 Package Table in J2SE

Package PackageName Description

Language [Link] The main class that is the core of


Java language
Utilities [Link] Class-class that supports structural utility
Java
I/O [Link] Class-class that supports various types
input and output type
Text [Link] Class that supports localization handling
text

Math [Link] Class for performing arithmetic calculations


arbitrary precision, either integer or floating point
AWT [Link] Class for user interface design and
event-handling
Swing [Link] Class for creating various components in
Java that behaves the same as various
platform

Javax Javax Extension of the Java language


Applet [Link] Class to create applet
Beans [Link] Class for creating Java Beans

[Link] Class for obtaining runtime information

SQL [Link] Class to support access and processing


data in the database
RMI [Link] Class for supporting distributed
programming
Networking [Link] Class to support in building
network application
Security [Link] Class to support cryptographic security

6
3. J2ME (Java 2 Micro Edition)

J2ME is a development environment designed to place

Java software for electronic goods along with its supporting devices.

J2ME, if the software framework functions well on a device, then it has not

of course it can also work well on other devices.

J2ME brought Java to the world of information, communication, and devices.

computation other than desktop computer devices that are usually smaller in size

desktop computer device. J2ME is commonly used on cell phones, pagers,

personal digital assistants (PDA) and similar types.

J2ME is part of J2SE, therefore not all libraries available in

J2SE can be used on J2ME. However, J2ME has several specific libraries.

which is not possessed by J2SE. The architecture of J2ME can be seen as in Figure 2.2.

Figure 2.2 J2ME Architecture

4. GUI (Graphical User Interface)

Class can be described as a templateht iw


fort ceme
jbo na e t aerc

characteristics

according to what is owned by that class. The class provides the ability for

object object built from that class. Classes can be viewed as

7
an overview of an object, while the actual form of the object in Java

called instance. The analogy is, suppose Class as a design image of a

building, then the instance is a building that has been constructed based on the design

Thus, there is actually no difference between Object and Instance, it's just that

object is a general definition while instance refers to the object

which is clearly visible. Both refer to the same object.

In Java, classes are grouped based on their general functions, for example

to create a program based on GUI (Graphical User Interface), or function

Others. This group is called a class library. Programming doesn't need to be cumbersome.

create a class library, because the existing development kit has created a library

in such a way that it is easy to use. For example, the [Link] library for

programming GUI. With this graphical-based program, processing databases

will become easier, besides having a more attractive appearance. Some parts

the basis of GUI is:

1. JLabel

JLabel nameLabel = new JLabel("label")

Just like its name, classini will create a label on a

window.

2. JTextField

JTextField nameText = new JTextField(max_character_count);

JTextField is a class that will facilitate the creation of forms.

text on a frame.

8
3. JButton

JButton nameButton = new JButton("label_on_button");

JButton is a class that will help create button objects.

4. JFrame

JFrame is actually a class provided to facilitate

in creating a window.

5. JInternalFrame

Similar to JFrame, JInternalFrame will assist in

create a window. The difference is that JInternalFrame will be inside a window.

other, so it cannot stand alone like JFrame.

6. JMenu

JMenu will create a menu bar object on a frame.

7. ActionListener

ActionListener is not an object, but a class.

that will accommodate the actions of an object (which is widely used

here is a button). These actions will be contained in a method named

ActionPerformed. So when using ActionListener, you must include

the ActionPerformed method in that class.

8. Container

[Link](new GridLayout(number_of_rows, number_of_columns));

9
The container will help organize the placement of objects such as text,

label or button. There are many ways provided to arrange

object placement. GridLayout will divide a window into several

rows and columns according to what was entered during setLayout. And placement

the object starts from the top left and then to the right.

Four main things to build a GUI-based program using

swing, that is:

1. Create and configure components to create GUI components

just like creating other objects in Java, by executing

constructor. Each component can be seen its characteristics in

Java documentation.

2. Adding a component to the container Each component in Java must

placed inside the container. The container in Java is found in

[Link]. The containers that are often used are JFrame and

JDialog. For web-based programs, you can use the Applet container.

in the [Link] class. The three containers are top-level.

container, which is the base container that serves as the foundation for the component

and other containers. In addition to the three above, there are still several other containers.

like JPanel.

3. Arranging the layout of components After placing the components in

container, so the component can have its size and layout adjusted. In addition

the color and shape can also be adjusted. To arrange the layout, the object that

used is LayoutManager.

10
4. Handling events generated by components

Components often experience events such as button clicks, frames.

move, and so on. Events are the result of user interaction and

This incident is further referred to as an event. So that the program can

therefore, an event listener is needed.

2. Netbeans

Netbeans is one of the IDE applications used by programmers to

writing, compiling, searching for errors, and distributing programs written in NetBeans

in Java language but can also support other programming languages. program

this is free to use

1. features in netbeans

• Smart code completion: suggests variable names from a certain type,

completing keywords and proposing parameter types for the method

• Using the code generator: with this feature we can

generate constructor, setter and getter method, dll.

• Error stripe: a feature that marks the rows with errors by highlighting them in red.

• Bookmarking: a feature used to mark lines that will be used at some point

we want to modify

• go to commands feature used to jump to declaration

variable, source code or file that exists in the same project.

11
3. Databases supported by NetBeans

• JDBC is the standard specification of the javasoft API that allows

java program to access the database management system.

• The JDBC API consists of a set of interfaces and classes written in the language

Java programming.

• ojdbc (Oracle Java Database Connectivity) is a driver that connects

Java and Oracle program

• mysql-connector-java is a driver that connects Java programs and

oracle

• JDBC-ODBC

• mySQL-server

[Link]

Operators are used to perform operations, calculation commands, and all actions.

that you want to include in the program. Okay, let’s go straight to the explanation below.

this.

1. Arithmetic Operator

(+) Addition operator (also as a string concatenator)

(-) Subtraction operator

(*) Multiplication operator

(/) Division operator

(%) Remainder operator

12
Arithmetic operators are used to perform mathematical operations, such as

addition, subtraction, division, and modulo (remainder). Example

usage:

Symbol Operator Name Example of Use


+ Addition n=n+1;
- Reduction n=n-1;
* Multiplication n=n*1;
/ Division n=n/1;
% Remainder of Division n=n%1;
+ String n="I"+"sleep";
[Link] Operator

(+) Operator plus; indicates a positive value (any number without this sign will be considered

as positive)

(-) Operator minus; indicates a negative value, can also be used for

negating a number

(++) Increment operator; adds one to a number

(--) Decrement operator; reducing a number by 1

(!) Opposite operator; reversing the value of a boolean

A unary operator only requires one operand to perform its operation.

This operator cannot be used for final variables, because final variables are of type.

a constant that cannot be changed. Several types of unary operators are provided on

the table below.

Operator Name Symbol Operation Example


+ More Expressing positive values angka = +1;
- Minus Stating a negative value number = -1;

13
++ Increase Adding a number to 1 number = ++number;
-- Decrease Reducing a number by 1 = --number;
! Opponent Invert the value of a boolean ok = !true
3. Operators of increase and decrease

It can be placed before or after a variable. If placed at

front (++x or --x), addition/subtraction is done beforehand, while

if placed at the end (x++ or x--) the addition/subtraction is performed

afterwards. However, in the end, both will result in x = x+1

or x = x-1. If the ++ operator is placed at the end (suffix), the value of "y" is the value of "x".

previously. Java will assign the value 'y' the value 'x' before the ++ operation is performed.

Only then is the value of 'x' added.

4. Comparison Operator, Boolean, and Condition

The conditional operator produces a true or false value depending on

from its variable, in this case, the operation is performed on two operands. Operator

boolean is a conditional operator whose two operands are boolean values (true or false)

false), while the Comparison Operator compares 2 values as in the operation

mathematics.

Note: In objects, such as String, comparison operations will compare the addresses.

the memory where the object is stored, not comparing its content. For

comparing String contents, use equals(), equalsIgnoreCase(), and compareTo()

as discussed in the previous section.

Symbol Operator Name Example


== Same as b=(1==2);

14
!= Not the same as b=(1!=2);
> Larger b=(1>2);
>= Greater than or equal to b=(1>=2);
< Smaller b=(1<2);
<= Less than or equal to b=(1<=2);
&& AND condition b=true&&false;
|| Operating Room Condition b=true||false;
! NOT condition b=!true;
?: Short form of "if then else"
5. Boolean AND Operator

The AND conditional operator produces 'true' if both of its operands are 'true'.

If either one or both are 'false', this operator produces 'false'. The following are

truth table of the AND operation.

Op1 or Exp1 Op2 or Exp2 Result


true true true
true false false
false true false
false false false
Operator && will evaluate Op2 (on the right) ONLY if operand 1

valued as "true". As seen from the table above, if Op1 (on the left) has a value of

"false", the result will always be "false" regardless of the content of Op2.

OR Condition Operator

The OR condition operator yields 'true' if at least one of its operands is 'true'. If

Both are 'false', this operator yields 'false'. Below is the truth table for the OR operation.

Op1 atau Exp1 Op2 atau Exp2 Hasil

15
true true true

true false true

false true true

false false false

7. The operator || will evaluate Op2 (on the right) ONLY if operand 1 is true.

"false". As seen from the table above, if Op1 (on the left) has the value of "true",

The result will always be 'true' regardless of the content of Op2.

8. Operator NOT

The NOT operator ('!') performs a boolean NOT operation on a single operand or expression.

This operator checks the boolean value of an operand or expression and then flips it.

the value changes (from true to false or false to true). The following is the truth table of the operator

NOT.

Op1 Result
True False
False True
9. Ternary Operator (?:)

Java has another conditional operator called ternary "?:", which essentially

is a shorthand form of if-then-else. Generally, condition ? if_true :

if_false Basically, the operator '?:' will evaluate the 'condition'. If the condition

evaluates to "true", the operator will return "if_true", but when "condition"

valued 'false', the operator will return 'if_wrong'.

16
c. Class, Object and Method

1. Class

The definition of Class, Object, and Method in Java is a blueprint or

a template for creating an instance of an object. a class is also a group of objects

with similarities in attributes/properties, behavior, and relationships to other objects.

Examples: Class Person, Vehicle, Tree, Fruit, and others.

2. Object

It is an instance of a class. If a class generally represents (a template)

an object, an instance is a real representation of the class itself.

Example: From the Fruit class, we can create objects like Mango, Banana, Apple, and others.
.

3. Attributes/ Variable

It is the value of the data that exists on an object that comes from a class.

Attributes represent the characteristics of an object. For example: in the Fruit Class.

terdapat attribute : warna, berat pada object mangga : warna berisi kuning dan berat

for example, 0.24 kg on the apple object: color contains red and weight is 0.30 kg

4. Method/Behavior

It is an operation in the form of functions that can be performed by a

An object. The method is defined in the class but is called through the object.

Example: on the mango object: there are methods getTaste, peelSkin, and others.

Method to determine the behavior of an object, namely what happens when the object is created.

as well as various operations that can be performed by an object throughout its lifetime.

The method has 4 (four) basic parts:

1. Name of the method

17
2. Object type or primitive type returned by the method.

3. List of parameters.

4. Body or content of the method.

The first three parts indicate important information about the method itself.

In other words, the name of the method is another method in the program. In Java we can

have different methods that have the same name but different return types

or the list of arguments, so the parts of the definition of this method become important. This

called method overloading.

To run a program that has polymorphic characteristics, it is necessary to

an overloading capability, which is an ability to determine which function

which should be used or executed if there is a function name that

Same. Polymorphism can be defined as the ability of a variable to change

behavior according to the instantiated object used. Polymorphism allows

more than 1 object from subclasses and treated as objects of the superclass

single.

d. Looping and Branching Structure

1. Looping

Repetition is a process within a program that can execute one (

several ) statements that are repeated until a stop condition is found.

In Java, there are three types of loops, namely for, while, and do while.

Structure for

The general form of the syntax for constructing a for loop

for(initialization; condition; iteration); {

18
statement 1 ;

statement 2;

The looping process will continue as long as the condition evaluates to true.

in other words, the repetition process will only stop when the condition has a value of false or

is no longer fulfilled.

While structure

The while structure is a type of loop that defines the condition at the beginning of the block. This

that is, if the condition is not met (equals false) then the repetition process will not occur.

will be done. The initialization process of values in the while structure is written before we

write the structure of the while itself, while the iteration will be written inside the block.

do-while structure

The do while loop is similar to the while loop. The statements inside the do-while loop will

executed several times while the condition is true. The difference between while and do while

A loop is where the statements inside a do while loop are executed at least once.

2. Branching

The program will be interesting if certain requirements are needed to run it.

statements, and bypass other statements. Java provides a number of mechanisms to

producing the setting of which part of the program runs, in the form of a statement

branching statements. There are several types of branching in Java, namely if, if-else, and

switch.

19
If branching

The if statement in Java indicates that the statement will be executed if the condition is met.

or certain conditions. The syntax of this branching is as follows:

If(condition){

Statemen1;

Statement2;

If else branching

This branch is to choose one of two possible occurrences. In other words

thus, the if else structure causes execution to run through a set of booleans,

only certain parts of the program are executed. Here is the general form of the if else statement:

If (condition)

Statement if the condition is true

Otherwise

The condition in the statement is false.

Switch branching

The switch statement provides a way to send parts of the program

based on the value of a variable or a single statement. The switch branching is intended

to handle many possible occurrences.

Object-Oriented Programming

Object-oriented programming (abbreviated as OOP)

is a programming paradigm that is oriented towards objects. All data and

Functions in this paradigm are wrapped in classes or objects. Compare.

20
with structured programming logic. Each object can receive messages, process

data, and sending messages to other objects,

Object-oriented data models are said to provide greater flexibility,

kemudahan mengubah program, dan digunakan luas dalamteknik piranti lunakskala besar.

Furthermore, proponents of OOP claim that OOP is easier to learn for

beginners compared to the previous approach, and the OOP approach is easier

developed and maintained.

21
CHAPTER III Experimental / Practical Results

a. Internship Module 1 / Creating a new project


In this first practical session, we will discuss how to create a new project in Java.

In this case, the author uses Netbeans IDE 8.0.1

Steps to create a new project in NetBeans:

1. Download netbeans at:[Link]

After the download is complete, install and run NetBeans.

3. Create a new project by clicking the File menu --> new Project so that the display appears

as follows.

22
4. In the Category choose Java and in the Project choose Java Application, click next to

continuing

5. In the Project Name, enter your project name, for example, Module1 concept set as Main

In the project, uncheck Create Main Class and then click Finish.

6. The project has been created, now create a class by right-clicking on the project name then

click new --> JFrameForm. After clicking JFrameForm, it appears as shown in the following image.

23
7. Enter the class name in Class Name, for example, Module1, then click Finish. Project Ready

used

24
b. Internship Module 2 / Creating a Biodata project

First, create a design like the image below:

Then enter the source code:

25
After finishing, right-click on the source code and select Run File, then it will appear

like this:

After that, enter your biodata and then click process, the result will be as follows:

26
c. Internship Module 3 / Creating a simple calculator

First, create a design like the image below:

Then enter the source code:

27
After finishing, right-click on the source code and select Run File, then it will appear.

like this:

After that, enter the first value and the second value, then click the button next to it.

right, in this case, I will choose the addition button, so the result is as follows:

Then I to choose button division hasilnya like following :

28
d. Internship Module 4 / Creating a sales project

First, create a design like the image below:

Then enter the source code:

29
After finishing, right-click on the source code and select Run File, then it will appear.

like this:

Enter the buyer's name, select status (general/member), select item type

(Ipad/Iphone/Ipod) and enter the quantity of items you want to purchase. Then click the button

pay.

30
First, I selected the status as general, so the result is as follows:

Then I chose the status as a member, with the same type of goods and quantity.

the same, then the difference is visible:

This is possible because as a member, a 5% discount is given from

the total price to be paid by the buyer.

31
e. Internship Module 5 / Creating an employee salary calculation project

First, create a design like the image below:

Then enter the source code:

32
33
34
After finishing, right-click on the source code and select Run File, then it will appear

seperti ini :

35
After that, enter the NIP, Name, and select the position (Director / manager / head of section / secretary /

karyawan / office boy), pilih status (Menikah / Belum menikah), jumlah anak jika sudah

marriage.

I will try to enter the employee's position, status is unmarried, so the result will be as

the following:

If I enter the same position but the status is married and has 2

child, so the result is as follows:

36
f. Internship Module 6 / multi document interface

First, create a design like the picture below:

Then enter the source code:

37
38
Add JInternalFrame Form to the project by selecting the File menu. New File select Project

you, then in Categories select Swing GUI Forms and in File Types select

JInternalFrame Form then click Next.

39
Fill in the Class name 'IFModul2' and Package 'MDI' then click Finish.

Open the previous Module 2 and then select the navigator item jDesktopPane1 right click

Copy.

Buka IFModul2 yang sebelumnya kemudian pilih navigator itemjInternalFrame click

rightPaste.

Do the same thing (follow steps n to p) to create the jInternalFrame file

Form for IFModule3, IFModule4, IFModule5.

After finishing, right-click on the source code and select Run File, then it will appear.

like this:

40
g. Internship Module 7 / Creating customer data project

First, create a design like the picture below:

Then enter the source code:

41
42
After finishing, right-click on the source code and select Run File, and it will display.

like this:

Then enter the name, phone number, and address, after that click save so that the data becomes

Your input will be automatically saved in the database.

The result is as follows:

43
If the entered data is incomplete, a message will appear stating

you to complete the data, as follows:

44
h. Internship Module 8 /

First, create a design like the image below:

Then enter the source code:

45
46
47
Right-click on cbojenis, then select Events -> Action -> actionPerformed.

Type the command code:

48
Right-click on btnbayar, then select Events -> Action -> actionPerformed.

Type the command code:

Right-click on txtnama then select Events -> Action -> MouseClicked.

Type the command code:

Right-click on the btnsimpan, then select Events -> ActionPerformed.

Type the command code:

Compile and run from the Run menu -> Run File or press Shift + F6.

49
CHAPTER IV Analysis of Experimental Results

a. Analysis of Practicum Module 2

Module 2 is a practical project on personal data whose aim is:

a. Create a Java program using a text editor and console in the environment.

[Link] syntax error from runtime error

c. Creating a Java program in NetBeans

b. Analysis of Practical Module 3

Module 3 is a practical exercise to create a simple calculator with the aim of:

a. Identifying the fundamentals of Java programming

b. Distinguishing several important aspects in Java such as Java literals, data types

primitive, variable type, identifier and operator.

c. Create a simple Java program using the existing concepts.

c. Analysis of Practical Work Module 4

Module 4 is a practical session to create a project about sales aimed at

studying the structure of conditions in this case is studying about

branching (if, else, switch). The program will be interesting if certain requirements are needed.

to execute a statement, and skip other statements. Java provides

a number of mechanisms to generate arrangements of which part of the program

executed, in the form of branching statements. there are several types

The branches in Java are if, if-else, and switch.

50
d. Analysis of Practicum Module 5

Module 5 is a practical project on employee salary calculations.


Writing commands using the Method function. Method contains lines of code.
commands to define the process or object of a class.

A method is a part of the code that can be called by the main program or

from other methods to run specific functions.

The following are the characteristics of the method, namely:

Must return one value or none at all

2. It should accept several parameters that are needed or there are no parameters.

not at all. Parameters can also be referred to as arguments of a function.

3. After the method has finished executing, it will return to the method

who calls him.

e. Analisa Praktikum Modul 6

Module 6 is a practical session on creating a Multi Document Interface (MDI).

its name, the MDI (Multiple Document Interface) application is an application that can

displaying multiple documents at once. An example of an MDI application is application software

Microsoft Word, Microsoft Excel and other application programs. In the MDI application, there is

2 divisions of the Form.

• Main Form: The outermost form used as a place (container) to display

another form.

• Child Form: The form displayed within the Parent Form. This form is installed.

as if stuck inside the main Form and unable to get out of

master form display.

51
f. Analysis of Practicum Module 7

Module 7 is a practical session on Creating Data Input Forms and Database Connections

MySQL aims for ease of application maintenance. Imagine if we

using many connection classes. Each class will connect to the database

using different methods. At some point, the application we are developing

It must connect to different databases, so there are certainly many codes that need to be changed.

Just create a class and a connection method. Create the class objects repeatedly.

call the method repeatedly. Or if necessary, inherit the connection class to the classes

next.

g. Analysis of Practicum Module 8

Module 8 is a continuation of practical 7 which is Creating a Data Input Form and

Connection to MySQL Database, in module 8 of this Sales Transaction program also

connecting to MySQL Database like Module 7. In Module 8, this program also

using 2Packages, namely Package Gui and Package Connection, Package Connection

This is what connects the Java Netbeans IDE program to the MySQL Database.

52
CHAPTER V: CONCLUSION

Conclusion

Java is one of the programming languages that has a complete Class.

with a series of advantages contained within it. With the API (Application) application program

Programming Interface) specifically developed as a communication intermediary

between software components. Java is used to create and

developing applications that support to facilitate human work.

With the rapid advancement of technology, it is also necessary

superior human resources in the context of that development.

This report is prepared with that background, the author intends to study

Java programming language from the most basic by creating a visual application program.

simple. By using the Java programming language, which has more advantages

compared to its weaknesses.

Suggestion

Thus, this Java Practicum Report is presented by the author regarding the practicum materials that

becomes the main topic of this report, of course, there are still many shortcomings and

its weaknesses. The author sincerely hopes for feedback and suggestions from the Java study instructor for

better improvement.

53
Bibliography

[Link]

[Link]

JAVA Programming: Loops & Branching

[Link]

EFTUTOR BLOG: Understanding Class, Object, and Method in Java

[Link]

Download Basic Java Learning Book | Eko Kurniawan

[Link]

Learn Basic to Advanced Java with an Ebook in Indonesian | Learning and Sharing Place

Knowledge of Java and PHP

[Link]

54

Common questions

Powered by AI

The ternary operator in Java is a shorthand for an if-then-else statement. It evaluates a boolean expression and returns one of two values based on whether the expression is true or false. The syntax is condition ? if_true : if_false. For example, the statement int result = (score > 60) ? 'pass' : 'fail'; checks if the variable score is greater than 60. If true, result is assigned 'pass'; otherwise, it is 'fail' . This operator provides a concise way to perform simple conditional logic within assignments.

The LayoutManager is responsible for arranging components within a Java container, controlling their sizes and positions. By specifying a particular layout, such as BorderLayout, FlowLayout, or GridLayout, developers can dictate how components will be displayed on the user interface, thus affecting the visual structure and usability of the application . The proper use of LayoutManager ensures efficient use of screen space and responsive design layout that adjusts with different screen sizes and resolutions.

Containers like JPanel and JDialog enhance the development of Java applications by providing structured environments to organize and display components. JPanel is often used as a generic lightweight container to group a set of components together within a specific area, enabling complex layouts and nested structures that promote modular design. JDialog, on the other hand, is used for creating pop-up dialogs or secondary windows, helping to separate and focus user interactions in an application. These containers facilitate better user interface management by making it easier to structure visual elements and control user input flow, thereby improving the overall user experience of Java applications .

JDBC (Java Database Connectivity) acts as an API that enables Java programs to connect to various database management systems (DBMS). It provides a standard interface for querying and updating databases, making Java applications database-agnostic . NetBeans supports drivers such as ojdbc for Oracle database connectivity and mysql-connector-java for MySQL. These drivers enable seamless database access from within Java applications developed in NetBeans . This set of APIs simplifies the database interaction process by ensuring that Java applications can connect to, and communicate with, the database in a standard manner.

Arithmetic operators in Java are used to perform mathematical operations, such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). For example, int result = 3 + 2; uses the addition operator to yield 5. Similarly, division is performed as int divisionResult = 10 / 2; giving 5. Java also allows for string concatenation using the addition operator: String greeting = "Hello " + "World!"; combines the two strings into "Hello World!" . These operators facilitate numerical calculations and string manipulations within Java applications.

Methods in Java classes are crucial as they define the behavior that objects instantiated from those classes can exhibit. A method is essentially a block of code that performs a specific operation or task and may return a value. When an object is created, its methods can be called to execute these operations, allowing the object to interact with other objects and perform calculations or actions. This encapsulation of behavior within methods contributes to maintaining the object-oriented principles of encapsulation, ensuring that internal states can only be accessed and modified through defined interfaces . Methods thus form the core functional aspects of an object, enabling dynamic interactions and operations within a Java application.

NetBeans offers several features that benefit Java developers by enhancing code management and error detection. The smart code completion feature assists programmers by suggesting variable names and keywords, thereby speeding up development time. The error stripe highlights lines of code with errors, making it easier for developers to identify and fix mistakes promptly. Furthermore, features like bookmark lines for quick access and the 'Go to' command for navigation within the project improve code management significantly . This combination of tools within NetBeans streamlines Java programming, allowing more focus on development rather than on repetitive error checking.

Unary operators, such as the increment (++) and decrement (--) operators, modify a single operand directly by either adding or subtracting one from the operand's value. For instance, the increment operator ++ can be used as ++x to increase the value of x by one before its value is used, or as x++ to increase it after its current value is used. However, unary operators cannot be used on final variables because final variables are constants, meaning their values cannot be changed once they are initialized .

Branching statements in Java are used to control program flow by executing specific code blocks based on conditional statements. The 'if' statement executes a block of code when a defined condition is true. An 'if-else' statement allows for a binary choice, executing one block if the condition is true and another if it is false, thereby providing an alternative path. The 'switch' statement is used when there are multiple potential execution paths based on the value of a variable or expression. It allows a program to execute different parts of code depending on the specific value it compares against multiple cases . These branching mechanisms allow developers to implement complex logic flows efficiently.

Object-oriented programming (OOP) in Java enhances software flexibility and scalability by encapsulating data and behavior within objects, allowing for modular design. Each object can operate independently and interact with other objects through well-defined interfaces. This leads to greater flexibility in terms of modifying and extending systems since new functionalities can be added with minimal impact on existing structures. OOP also facilitates code reuse through inheritance and polymorphism, making codebases more scalable as new classes can extend existing ones to expand capabilities without duplicating code . Proponents claim that OOP is easier to learn and adapt, thus supporting more efficient development for large-scale software projects.

You might also like