Lab 1 BSCS 13C
Lab 1 BSCS 13C
Date: 01-02-2024
Time: 2:00pm- 5:00 pm
Instructor: Mr. Jaudat Mamoon
Lab Engineer: Mr. Danyal Sadiq
After completing this lab students will be able to do some printing task in Java.
Objectives
Your first activity will be creating the "Hello World" program using Java.
Tools/Software Requirement
NetBeans. Eclipse
Description
Stuck? Confused? Have a question? Ask a TA/Lab Engineer for help, or look at the book
or past lecture slides.
Before you leave today, make sure to check in with one of the Lab Engineers/TAs in the
lab to get credit for your work.
Activity #1.
Your first task will be creating the "Hello World" program using java. Create a new directory
CS-212, and navigate into it. Using notepad or the editor of your choice (preferably NetBeans),
create a file called ActivityOne.java and enter the following code:
javac ActivityOne.java
If you get any compiler messages, then the learning process has already started! Make sure the
name of the file and the name of the class are identical, that you're in the right place in the
directory structure, and the code is exactly as shown above.
java ActivityOne
After getting the program to work, let's see what happens if we deliberately break it. We'll try
several variations that violate java syntax to learn what happens. Watch carefully to see what
message the compiler generates for each of these small errors—they are mistakes every
programmer makes on a regular basis.
1) Start by changing the name of the class in the first line, saving the file, and then attempt
to re-compile it with the javac/NetBeans Build command. Observe what happens.
2) Now restore the name in the class header and try removing one of the opening braces,
then save and compile again. Put the brace back and remove the closing brace that
matched it, and save and compile again. Make a note of the messages the compiler
generates for each change.
3) Try a version with a lowercase "s" at the beginning of the output statement instead of the
uppercase "S."
4) Finally, try a version where the only change is the removal of the semicolon at the end of
the print statement. This is a mistake every programmer makes more than once—it's good
to see how the compiler responds.