0% found this document useful (0 votes)
49 views

Week001 LabEx

The document discusses an introductory laboratory exercise on Java programming. It instructs the student to write a simple Java program that prints a message, save and compile it. It then has the student make changes to the class name, file name, and method name and observe the results of compiling each time to understand how Java programs work. The questions at the end test the student's understanding of the key steps and outputs.

Uploaded by

Mau Gamon
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Week001 LabEx

The document discusses an introductory laboratory exercise on Java programming. It instructs the student to write a simple Java program that prints a message, save and compile it. It then has the student make changes to the class name, file name, and method name and observe the results of compiling each time to understand how Java programs work. The questions at the end test the student's understanding of the key steps and outputs.

Uploaded by

Mau Gamon
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Programming 2

1
Introduction to Java Technology

Week001 – Introduction to Java Technology


Laboratory Exercise 001

Objective/s:
At the end of this activity, you should be able to:
 Deconstruct how a Java program works
 Identify the different ways on how to run a simple java program

What to Prepare for the Activity:


 Java Standard Edition (SE) Development Kit 8 (JDK8) which could be downloaded from
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-
2133151.html

 A text editor, an example of this is Notepad or Notepad++.

Procedure:
1. We will be writing a simple java program and try to deconstruct and understand the
different phases of a java program.
a. Open your text editor and type in the following code:
public class FirstLaboratory {

public static void main(String[] args) {


System.out.println("This is my first laboratory exercise");
}

b. Save it as FirstLaboratory.java and compile.

Test Stem / Question Choices


1: Open the generated file from the directory. A: Byte codes
What does it contain?
B: The same code that is written

C: Binary data

D: Empty

2: What is the file name of the generated file? A: FirstLaboratory.class

B: .class

Assessments
C: FirstLaboratory.javaclass

D: FirstLaboratory.javac

3: What does the console say? A: This is my first laboratory exercise.

B: FirstLaboratory

C: Hello World

D: System.our.println(“This is my first laboratory


exercise”)

2. Open your text editor and change the class name to MyFirstLaboratory, save it and compile.

Test Stem / Question Choices


4: What happens? A: Code did not compile.

B: Code was compiled successfully.

C: Compiled successfully but with errors.

D: Compiled successfully but did not print.

5: What is the file name of the generated file? A: FirstLaboratory.class

B: MyFirstLaboratory.class

C: MyFirstLaboratory.class

D: There’s no generated file.

3. Change the file name of your java code to MyFirstLaboratory, Save and compile.

Test Stem / Question Choices


6: What happens? A: Code did not compile.

B: Code was compiled successfully.

C: Compiled successfully but with errors.

D: Compiled successfully but did not print.

7: What is the file name of the generated file? A: FirstLaboratory.class


Computer Programming 2
3
Introduction to Java Technology

B: MyFirstLaboratory.class

C: MyFirstLaboratory.class

D: There’s no generated file.

3. Now change the public static void main to public static void main2. Save it and
compile.

Test Stem / Question Choices


8: What happens? A: Code did not compile.

B: Code was compiled successfully.

C: Compiled successfully but with errors.

D: Compiled successfully but did not print.

9: What is the file name of the generated file? A: FirstLaboratory.class

B: FirstLaboratory.java

C: MyFirstLaboratory.java

D: MyFirstLaboratory.class

10: What does the console say? A: This is my first laboratory exercise.

B: FirstLaboratory

C: Nothing

D: System.our.println(“This is my first laboratory


exercise”)

Assessments

You might also like