Professional Documents
Culture Documents
1
Java Language Fundamentals
Objective/s:
At the end of this activity, you should be able to:
Write a program based on the knowledge of different parts of a java program.
Apply the coding standards for the different parts of the program.
Write a program with proper comments and documentation.
Procedure:
1. Write a simple java program with the following specification:
a. Create a java file named LaboratoryExercise2
b. Create a variable with ‘int’ data types without initializing it.
c. Print the variable using System.out.println()
d. Save and compile.
B: nothing
2: What is the output when you run the B: The program will not run because of the compiler
program? error
B: nothing
C: 0
D: Hello World!
Assessments
2. Open the file that you have created and replace the entire codes with this:
public class LaboratoryExercise2 {
public static void main(String[] args) {
System.out.println("\"Hello\" world!");
}
}
B: nothing
C: Compiler warning
C: “Hello World!”
D: “Hello” World!
B: nothing
Computer Programming 2
3
Java Language Fundamentals
C: Compiler warning
C: a
D: “Hello” World!
B: nothing
C: Compiler warning
C: A
B: nothing
Assessments
C: Compiler warning
C: a
Only nos. 6 and 7 will be uploaded to the link provided on the course page.
The filename for No. 6 should be Lab2_6 and Lab2_7 for no. 7.
Only Java files will be accepted.
Since there are multiple Java files, save them into one folder. The folder name should be
in this format:
Lab002_<lastname_firstname>
Example: Lab002_Blanco_Maria
Compress the folder into .rar or .zip format before uploading.
6. Write a Java program that will display the text below including the new line.
"I am writing a program that will display "text" with escape characters.
At the beginning of this sentence it has tab escape character.
There are two new lines before this sentence and you also have to
include 'single quote' and \back slash\ characters in this sentence."
7. From the given the table below, write a program that display the names together with the
values.
The variables should have valid names (should follow coding guidelines)
Correct initial value and data types that fit on the initial value.
Write comments for each statement. The comment should clearly describe the
statement.
Age 1
Computer Programming 2
5
Java Language Fundamentals
Final false
Location 0x11
Default ‘a’
Name “noname”
Assessments