Lab Assignment 1 Solution

Objective:




To become familiar with Java programming language



To understand the very basic concepts of java such as the concept of classes, main method, and errors.



Machine Details:




Complete this assignment by yourself on your PC/laptop after installing jGRASP or any other Java development environment. You may also use the lab (ENB116) machines or CIRCS.




Assignment Description:




Read Chapter 1 from the book.



Write a simple Java Program that outputs your name to the screen, following the word Hello (60%)
Compile the following code and report the number and type of errors: (20%) public class SimpleClass {



public static viod main (string[] args)




{ system.out.println(“Hello World”): }




}




If the code doesn’t compile due to error, submit the correct version of the code.




Compile the following code and report the number and types of error: (20%) public class SimpleClass {
public static void main (String[] args) { int x;

x=0;

system.out.println(5/x); } }




If the code doesn’t compile due to error, submit the correct version of the code.













Grading:




For full credit, your implementation must:




Compile, runs correctly and provide the required output; a program that doesn’t compile will result in zero.
Be formatted appropriately; please check indentation and alignment of code within blocks.
Be commented. There should be a comment for the entire class briefly saying what it does. Since these programs have only one class with one method (main), the main method is essentially identical to the class. Don't require a header comment for both. A comment on either one is sufficient.



Have Fun! J