Starting from:

$25

CSE110 - Principles of Programming with Java - LAB 1  - Solved

1.       Type the following file into TextPad adding your name and lab letter. Make sure your file is called Lab1.java. It does not work if you copied it. 

 Compile and run the program. What is the output?  

  

2.       The System.out.println(""); causes whatever is in between the “” to be printed to the console and whatever comes next to be printed on a new line. Add a line to the program so that it will print out your name before printing out “This is my first program!”. So an example output should be:  

  

Hello, my name is James Bond.  This is my first program!  

  

After modifying your program compile and run it again and check the output is correct.  

  

3.       The System.out.print (""); command will print whatever is in between the “ ” but will print whatever is next immediately after it. To see how this works, delete the “ln” from the end of the first print statement (that prints your name) and compile and run again. Now what is the output?  

  

4.       Change the program back so you get the same output in part 2. Be sure to compile and test the program again.  

  

More products