SlideShare a Scribd company logo
1 of 11
Download to read offline
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 1
LAB 1 – Introduction to Java
Objectives:
At the end of this lab, students are able to:
i. To write simple Java Programs
ii. To display output on console Java
iii. To create, compile, and run Java program
iv. To display output using the JOptionPane output dialog boxes
1.1 Activity 1
1.1.1 Objective
To write a simple Java program using IDE TextPad.
1.1.2 Problem Description
You have been assigned to write a simple HelloWorld program using TextPad application. The program
should be able to display a message "Hello World. This is my first time using Java".
[Estimated Time: 30 minutes]
1.1.3 Solution Activity 1
Step 1:Go to CSF3102 –> Lab-Module1’s folder and create Sub-working folder called Activity1. If the
folders do not exist, create the folder first.
Step 2: Open IDE TextPad. Go to Start --> Search --> Type "TextPad".
Step 3: Create new file/class called HelloWorld.java save it into CSF3102Lab-Module1Activity1.
Step 4: Complete the coding as below.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 2
Step 5: Save the HelloWorld.java’s file.
Step 6: Compile the program.
Step 6.1: Open Command Prompt. Go to Start --> Search --> Type "cmd". The Command Prompt window
will appear as below
Step 6.2: Go to the current folder where the HelloWorld.java is located using the command below.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 3
Step 6.3: Compile HelloWorld.java using the command below.
Step 7: Run and evaluate the output using the command below.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 4
1.2 Activity 2
1.2.1 Objective
To write a simple Java program using IDE NetBeans.
1.2.2 Problem Description
You have been assigned to write a simple WhoAmI program using NetBeans application. The program
should be able to display a message "Muhammad Abdullah. UK Number: SS11111. Program of Computer
Science (Software Engineering)".
[Estimated Time: 30 minutes]
1.2.3 Solution Activity 2
Step 1: Go to CSF3102 –> Lab-Module1’s folder and create Sub-working folder called Activity2.
Step 2: Open IDE Netbeans.
Step 3: In the IDE, choose File -> New Project (Ctrl-Shift-N), as shown in the figure below.
Step 4: In the New Project wizard, expand the Java category and select Java Application as shown in the
figure below. Then click Next.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 5
Step 5: In the Name and Location page of the wizard, do the following (as shown in the figure below):
 In the Project Name field, type Activity2.
 Browse Project Location to CSF3102Lab-Module1
 Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.
 In the Create Main Class field, type activity2.WhoAmI.
 Leave the Set as Main Project checkbox selected.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 6
The project is created and opened in the IDE. You should see the following components:
 The Projects window, which contains a tree view of the components of the project, including
source files, libraries that your code depends on, and so on.
 The Source Editor window with a file called WhoAmI.java is open.
 The Navigator window, which you can use to quickly navigate between elements within the
selected class.
 The Output window, which lists compilation errors as well the output.
Step 6: Adding Code to the Generated Source File. Because you have selected the Create Main Class
checkbox in the New Project wizard, the IDE has created a skeleton main class for you. You can add the
"Muhammad Abdullah. UK Number: SS11111. Program of Computer Science (Software Engineering)"
message to the skeleton code by replacing the line:
// TODO code application logic here
with the line:
System.out.println("Muhammad Abdullah. UK Number: SS11111. Program of
Computer Science (Software Engineering)");
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 7
Step 7: Save the change by choosing File -> Save. The file should look something like the following code.
Step 8: Compiling the program. Go to Run -> Compile File (F9). Next, you should see the output window
shows the compilation messages as below .
If there are compilation errors, they are marked with red glyphs in the left and right margins of the Source
Editor. The glyphs in the left margin indicate errors for the corresponding lines. The glyphs in the right
margin show all of the areas of the file that have errors, including errors in lines that are not visible. You
can mouse over an error mark to get a description of the error. You can click a glyph in the right margin to
jump to the line with the error.
Step 9: Running the Program. Go to Run -> Run Project (F6). Next, you should see the output window
displays the result as below.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 8
Step 10: Building and Deploying the Application. Choose Run > Clean and Build Main Project (Shift+F11)
Once you have written and test run your application, you can use the Clean and Build command to build
your application for deployment. When you use the Clean and Build command, the IDE runs a build script
that performs the following tasks:
 Deletes any previously compiled files and other build outputs.
 Recompiles the application and builds a JAR file containing the compiled files.
Step 11: You can view the build outputs by opening the Files window and expanding the Activity2 node.
The compiled bytecode file WhoAmI.class is within the build/classes/activity2 sub node. A deployable JAR
file that contains the WhoAmI.class is within the dist node.
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 9
1.3 Activity 3
1.3.1 Objective
To write a simple program that can display multiple messages in several lines.
1.3.2 Problem Description
You have been assigned to write a simple MyProfile program using NetBeans application. The program
should be able to display a message as shown below:
[Estimated Time: 30 minutes]
1.4 Activity 4
1.4.1 Objective
To create, compile, run and examine a Java program.
1.4.2 Problem Description
You have been assigned to write a simple SelamatDatang program using NetBeans application. The
program should be able to produce a message "Selamat Datang ke UMT". Based on the written program,
answer the following questions:
i. Replace the class with Class. What happened? If error occurs, discuss the reason why the
error occurs.
ii. Replace the main with Main. What happened? If error occurs, discuss the reason why the error
occurs.
iii. Remove the semicolon at the end of the println statement. Explain what happened.
[Estimated Time: 30 minutes]
Resume
Name: Muhammad Abdullah.
Address: 1234, Jalan 5, Kampung 6, 78910, Kuala Terengganu, Terengganu
UK Number: SS11111.
Program: Program of Computer Science (Software Engineering)
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 10
1.5 Activity 5
1.5.1 Objective
To examine, identify and fix the errors.
1.5.2 Problem Description
1. Identify and fix the errors in the following code. Write a FixErrors.java to fix the errors.
2. What is wrong with the following program statement? Rewrite the statement in Test.java to fix
the error.
3. What is the output produce if the following codes are added after the previous println
statement as in question 2? Explain the result.
[Estimated Time: 30 minutes]
public class FixErrors
{
Public static void main(string[] args)
{
System.out.print(Welcome!);
}
}
System.out.println('To be or not to be, that is the question.');
System.out.print ("Show me the answer.");
System.out.println("I'll give you the answer.");
MODULE 1 INTRODUCTION TO JAVA
PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 11
1.6 Activity 6
1.6.1 Objective
To display output using the JOptionPane output dialog boxes
1.6.2 Problem Description
You have been assigned to write a simple WelcomeInMessage program using the JOptionPane output
dialog boxes. The program should be able to display a message "Welcome to Java". The code is below.
1. Compile and run WelcomeInMessageBox.java. What is the output of the code?
2. Rewrite the code that produces the output below:

More Related Content

What's hot

Cis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comCis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comBaileya126
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7comp274
 
Chapter 01: Intro to VB2010 Programming
Chapter 01: Intro to VB2010 ProgrammingChapter 01: Intro to VB2010 Programming
Chapter 01: Intro to VB2010 Programmingpatf719
 
Lab 1: Uploading a file to create an artifact
Lab 1: Uploading a file to create an artifactLab 1: Uploading a file to create an artifact
Lab 1: Uploading a file to create an artifactIBM Rational software
 
Chapter 01
Chapter 01Chapter 01
Chapter 01llmeade
 
CIS 170 Become Exceptional--cis170.com
CIS 170 Become Exceptional--cis170.comCIS 170 Become Exceptional--cis170.com
CIS 170 Become Exceptional--cis170.comclaric131
 
Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7helpido9
 
CIS 170 Redefined Education--cis170.com
CIS 170 Redefined Education--cis170.comCIS 170 Redefined Education--cis170.com
CIS 170 Redefined Education--cis170.comagathachristie208
 
CIS 170 Education for Service--cis170.com
CIS 170 Education for Service--cis170.comCIS 170 Education for Service--cis170.com
CIS 170 Education for Service--cis170.comwilliamwordsworth11
 
CIS 170 Inspiring Innovation -- cis170.com
CIS 170 Inspiring Innovation -- cis170.comCIS 170 Inspiring Innovation -- cis170.com
CIS 170 Inspiring Innovation -- cis170.comkopiko104
 

What's hot (10)

Cis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comCis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.com
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7
 
Chapter 01: Intro to VB2010 Programming
Chapter 01: Intro to VB2010 ProgrammingChapter 01: Intro to VB2010 Programming
Chapter 01: Intro to VB2010 Programming
 
Lab 1: Uploading a file to create an artifact
Lab 1: Uploading a file to create an artifactLab 1: Uploading a file to create an artifact
Lab 1: Uploading a file to create an artifact
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
CIS 170 Become Exceptional--cis170.com
CIS 170 Become Exceptional--cis170.comCIS 170 Become Exceptional--cis170.com
CIS 170 Become Exceptional--cis170.com
 
Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7
 
CIS 170 Redefined Education--cis170.com
CIS 170 Redefined Education--cis170.comCIS 170 Redefined Education--cis170.com
CIS 170 Redefined Education--cis170.com
 
CIS 170 Education for Service--cis170.com
CIS 170 Education for Service--cis170.comCIS 170 Education for Service--cis170.com
CIS 170 Education for Service--cis170.com
 
CIS 170 Inspiring Innovation -- cis170.com
CIS 170 Inspiring Innovation -- cis170.comCIS 170 Inspiring Innovation -- cis170.com
CIS 170 Inspiring Innovation -- cis170.com
 

Similar to Csf3108 lab module 1 (1)

Gui application for e mail application
Gui application for e mail applicationGui application for e mail application
Gui application for e mail applicationUmesh Mk
 
Prg 218 entire course
Prg 218 entire coursePrg 218 entire course
Prg 218 entire coursegrades4u
 
VB.NET programming
VB.NET programmingVB.NET programming
VB.NET programmingElrey Belga
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfacesdjdskjd9097
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   llflowe
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   bellflower42
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com amaranthbeg143
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.combellflower82
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lecturesmarwaeng
 
openGl configuration_in visual studio 2019.pptx
openGl configuration_in visual studio 2019.pptxopenGl configuration_in visual studio 2019.pptx
openGl configuration_in visual studio 2019.pptxMuhammadUmer787617
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayLiz Sims
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applicationstechbed
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thRishi Kumar
 
Hello android example.
Hello android example.Hello android example.
Hello android example.Rahul Rana
 
Cis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comCis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comBaileyao
 

Similar to Csf3108 lab module 1 (1) (20)

Gui application for e mail application
Gui application for e mail applicationGui application for e mail application
Gui application for e mail application
 
Prg 218 entire course
Prg 218 entire coursePrg 218 entire course
Prg 218 entire course
 
VB.NET programming
VB.NET programmingVB.NET programming
VB.NET programming
 
MD51 Lab Manual
MD51 Lab ManualMD51 Lab Manual
MD51 Lab Manual
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interface
 
Supplement2d netbeans6
Supplement2d netbeans6Supplement2d netbeans6
Supplement2d netbeans6
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
Gui builder
Gui builderGui builder
Gui builder
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
openGl configuration_in visual studio 2019.pptx
openGl configuration_in visual studio 2019.pptxopenGl configuration_in visual studio 2019.pptx
openGl configuration_in visual studio 2019.pptx
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage Essay
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applications
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12th
 
Hello android example.
Hello android example.Hello android example.
Hello android example.
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
 
Cis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comCis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.com
 
Getting started with android studio
Getting started with android studioGetting started with android studio
Getting started with android studio
 

Recently uploaded

Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Onlineanilsa9823
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 

Recently uploaded (20)

Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 

Csf3108 lab module 1 (1)

  • 1. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 1 LAB 1 – Introduction to Java Objectives: At the end of this lab, students are able to: i. To write simple Java Programs ii. To display output on console Java iii. To create, compile, and run Java program iv. To display output using the JOptionPane output dialog boxes 1.1 Activity 1 1.1.1 Objective To write a simple Java program using IDE TextPad. 1.1.2 Problem Description You have been assigned to write a simple HelloWorld program using TextPad application. The program should be able to display a message "Hello World. This is my first time using Java". [Estimated Time: 30 minutes] 1.1.3 Solution Activity 1 Step 1:Go to CSF3102 –> Lab-Module1’s folder and create Sub-working folder called Activity1. If the folders do not exist, create the folder first. Step 2: Open IDE TextPad. Go to Start --> Search --> Type "TextPad". Step 3: Create new file/class called HelloWorld.java save it into CSF3102Lab-Module1Activity1. Step 4: Complete the coding as below.
  • 2. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 2 Step 5: Save the HelloWorld.java’s file. Step 6: Compile the program. Step 6.1: Open Command Prompt. Go to Start --> Search --> Type "cmd". The Command Prompt window will appear as below Step 6.2: Go to the current folder where the HelloWorld.java is located using the command below.
  • 3. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 3 Step 6.3: Compile HelloWorld.java using the command below. Step 7: Run and evaluate the output using the command below.
  • 4. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 4 1.2 Activity 2 1.2.1 Objective To write a simple Java program using IDE NetBeans. 1.2.2 Problem Description You have been assigned to write a simple WhoAmI program using NetBeans application. The program should be able to display a message "Muhammad Abdullah. UK Number: SS11111. Program of Computer Science (Software Engineering)". [Estimated Time: 30 minutes] 1.2.3 Solution Activity 2 Step 1: Go to CSF3102 –> Lab-Module1’s folder and create Sub-working folder called Activity2. Step 2: Open IDE Netbeans. Step 3: In the IDE, choose File -> New Project (Ctrl-Shift-N), as shown in the figure below. Step 4: In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.
  • 5. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 5 Step 5: In the Name and Location page of the wizard, do the following (as shown in the figure below):  In the Project Name field, type Activity2.  Browse Project Location to CSF3102Lab-Module1  Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.  In the Create Main Class field, type activity2.WhoAmI.  Leave the Set as Main Project checkbox selected.
  • 6. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 6 The project is created and opened in the IDE. You should see the following components:  The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.  The Source Editor window with a file called WhoAmI.java is open.  The Navigator window, which you can use to quickly navigate between elements within the selected class.  The Output window, which lists compilation errors as well the output. Step 6: Adding Code to the Generated Source File. Because you have selected the Create Main Class checkbox in the New Project wizard, the IDE has created a skeleton main class for you. You can add the "Muhammad Abdullah. UK Number: SS11111. Program of Computer Science (Software Engineering)" message to the skeleton code by replacing the line: // TODO code application logic here with the line: System.out.println("Muhammad Abdullah. UK Number: SS11111. Program of Computer Science (Software Engineering)");
  • 7. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 7 Step 7: Save the change by choosing File -> Save. The file should look something like the following code. Step 8: Compiling the program. Go to Run -> Compile File (F9). Next, you should see the output window shows the compilation messages as below . If there are compilation errors, they are marked with red glyphs in the left and right margins of the Source Editor. The glyphs in the left margin indicate errors for the corresponding lines. The glyphs in the right margin show all of the areas of the file that have errors, including errors in lines that are not visible. You can mouse over an error mark to get a description of the error. You can click a glyph in the right margin to jump to the line with the error. Step 9: Running the Program. Go to Run -> Run Project (F6). Next, you should see the output window displays the result as below.
  • 8. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 8 Step 10: Building and Deploying the Application. Choose Run > Clean and Build Main Project (Shift+F11) Once you have written and test run your application, you can use the Clean and Build command to build your application for deployment. When you use the Clean and Build command, the IDE runs a build script that performs the following tasks:  Deletes any previously compiled files and other build outputs.  Recompiles the application and builds a JAR file containing the compiled files. Step 11: You can view the build outputs by opening the Files window and expanding the Activity2 node. The compiled bytecode file WhoAmI.class is within the build/classes/activity2 sub node. A deployable JAR file that contains the WhoAmI.class is within the dist node.
  • 9. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 9 1.3 Activity 3 1.3.1 Objective To write a simple program that can display multiple messages in several lines. 1.3.2 Problem Description You have been assigned to write a simple MyProfile program using NetBeans application. The program should be able to display a message as shown below: [Estimated Time: 30 minutes] 1.4 Activity 4 1.4.1 Objective To create, compile, run and examine a Java program. 1.4.2 Problem Description You have been assigned to write a simple SelamatDatang program using NetBeans application. The program should be able to produce a message "Selamat Datang ke UMT". Based on the written program, answer the following questions: i. Replace the class with Class. What happened? If error occurs, discuss the reason why the error occurs. ii. Replace the main with Main. What happened? If error occurs, discuss the reason why the error occurs. iii. Remove the semicolon at the end of the println statement. Explain what happened. [Estimated Time: 30 minutes] Resume Name: Muhammad Abdullah. Address: 1234, Jalan 5, Kampung 6, 78910, Kuala Terengganu, Terengganu UK Number: SS11111. Program: Program of Computer Science (Software Engineering)
  • 10. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 10 1.5 Activity 5 1.5.1 Objective To examine, identify and fix the errors. 1.5.2 Problem Description 1. Identify and fix the errors in the following code. Write a FixErrors.java to fix the errors. 2. What is wrong with the following program statement? Rewrite the statement in Test.java to fix the error. 3. What is the output produce if the following codes are added after the previous println statement as in question 2? Explain the result. [Estimated Time: 30 minutes] public class FixErrors { Public static void main(string[] args) { System.out.print(Welcome!); } } System.out.println('To be or not to be, that is the question.'); System.out.print ("Show me the answer."); System.out.println("I'll give you the answer.");
  • 11. MODULE 1 INTRODUCTION TO JAVA PPIMG, UMT | CSF3108 –PROGRAMMING SEM I 2018/2019 11 1.6 Activity 6 1.6.1 Objective To display output using the JOptionPane output dialog boxes 1.6.2 Problem Description You have been assigned to write a simple WelcomeInMessage program using the JOptionPane output dialog boxes. The program should be able to display a message "Welcome to Java". The code is below. 1. Compile and run WelcomeInMessageBox.java. What is the output of the code? 2. Rewrite the code that produces the output below: