-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab 1.txt
43 lines (21 loc) · 1.27 KB
/
Lab 1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Lab 1 –Introduction to Java Programming
Answer the following questions.
TASK 1:
Create a source file containing a Java program. Perform the following steps to compile the program and run it.
1. Create a file named Welcome.java. You can use any editor that will save your file in text format.
public class Welcome {
/* @param args the command line arguments */
public static void main(String[] args) {
System.out.println("Welcome to Java.");
}
}
2. Compile the source file.
3. Run the bytecode.
4. Replace “Welcome to Java” with “My first program” in the program; save, compile, and run the program. You will see the message “My first program” displayed.
5. Replace main with Main, and recompile the source code. The Interpreter returns an error message because the Java program is case-sensitive.
6. Change it back, and compile the program again.
7. If you use command-line,
a. Instead of the command javac Welcome.java, use javac welcome.java. What happens?
b. Instead of the command java Welcome, use java Welcome.class. What happens?
TASK 2:
Write the same program in Netbeans IDE or equivalent. Understand the Project File Structure (packages and Java files) and state the difference between the “Run Project” and “Run File”.