ComS 207: Homework 1

Student Name:

Recitation Section:

1.1 Compiling a Java program


Create a file called "Hello.java" and type in the following program,
inserting your name when asked.

Compile Hello.java using jGRASP.

Run the program in jGRASP.

Great! You have compiled and ran your first Java program.

IMPORTANT: Make sure that your program compiles and runs as expected before continuing to 1.2.

1.2 Fixing Compiler Errors

Insert the following errors one at a time into your program, and write down what happens when you try to compile. IMPORTANT: When you are done with each error restore the file to its original form and then introduce the next error (do NOT introduce more than one error at a time).

a) Change the word "main" to "mAin".





b) Remove the semicolon ";" at the end of the print statement.





c) Remove the last closing bracket "}".





d) Change the quotes from double quotes " to single quotes '.





e) Remove the first opening bracket "{"





f) Change "System.out.println" to "System.outside.println".





g) Delete the '/' on line 4.





h) Replace 'args' with 'parameters'




1.3 More Errors

Using the same program as in 1.1 introduce three more bugs of your own choice. For each bug describe what you changed and what was the result (as in 1.2).

a) ____________________________________






b) ____________________________________






c) ____________________________________





1.4 Even More Errors

Each of the two programs below has 3 errors. Can you find them?

If you want you can type in the programs, but after doing 1.2 and 1.3 you should be able to find the errors by just reading the source code.

a) Program 1:

/*****************************************************
 * My Buggy Program
 *
 **************************************************** /
public class Buggy1
{
	public static void main(String][ args)
	{
		System.out.println("Java rocks!!"};
	}
}


b) Program 2:
public 
class 
Buggy2 
{ 
public 
static 
void 
main(
String[] 
params)
{{
System.
out..
println(
''Java rocks!!''
);
}}

What to Submit

Print this web page. Put your name and all of your answers on the printout. Submit the printout *BEFORE* the start of class on Friday, August 31.

IMPORTANT: No late homeworks will be accepted.