Java
TOPIC 05 – YOUR FIRST JAVA PROGRAM
LESSON WORK
QUESTION 1
(GROUP)
Mr. Campeau will help you run your first program.
The work will
be done inside the project named Topic05. This will be saved inside the folder that
you designated as your workspace.
QUESTION 2
Create a program called MyFirstProgram. It should output to screen "Mr. Campeau is the best!" (or any other message that you want).
QUESTION 3
Examine the
code below and find the error (if there is one). You can test your answer by
copying and pasting your code into Eclipse and trying to run it.
a)
public class ErrorFinder1
{
public static void main(String[] args)
{
System.out.println("Yo!")
}
}
|
b)
public class ErrorFinder2
{
public static main void(String[] args)
{
System.out.println("Yo!");
}
}
|
c)
public class ErrorFinder3
{
public static void main(String[] args)
{
System.out.Println("Yo!");
}
}
|
d)
public ErrorFinder4
{
public static void main(String[] args)
{
System.out.println("Yo!");
}
}
|
e)
public class ErrorFinder5
{
public static void main(String[] args)
{
System.out.println("Yo!");
}
}
|
f)
public class ErrorFinder6
{
public static void main(String[] args)
System.out.println("Yo!");
}
}
|
QUESTION 4 (TIME
PERMITTING)
Now that you
have ran a Java program, you can go explore the content of your Topic05
folder. You should find your source
code in a .java file. But, you should
also find another file that contains the Java bytecode version of your file. What is its file extension?
To find this
answer, you need to go look inside your workspace (from Windows, not from
Eclipse).
QUESTION 5
(TIME PERMITTING)
WARNING:
Special symbols are not displaying correctly on the most recent version of
Eclipse. Unfortunately, we will skip
this question until a solution can be found.
Find a website that allows you to create text art (such as https://fsymbols.com/draw/). Create some text art (such as a dungeon map
or a neat title). Copy and paste that
text art to a program and simply make the program output it. Note that you will have to output each line
one at a time.
If Eclipse gives you an error when
saving your file with the new symbols, you will have to change the
character set for the project. Do
the following:
1. Window > Preferences
2. General > Workspace
3. Under
Text File Encoding, pick Other and UTF-8.
|
|