You are on page 1of 11

PROGRAMMING ASSIGNMENT

LAB 1

Questions:

A. Write a program to print your name, address and hobby.


B. Write a program to add five numbers and print the result.

C. Write a step wise complete procedure to run a JAVA program in BlueJ with screenshots.

Ans: Following are the some steps to run a JAVA program in BlueJ :

1) Click on Project.
2. Click on New Project.

3. Write your project name as per your given project. For Eg; I want to create a project name
as demoproject. So, I will write demoproject in Project Name. And click on ‘OK’ button.
4. Your project file will be open. Then, click on the New Class.

5. Write Class Name as per your project. For eg; I will write democlass in Class Name. After
this click on ‘OK’ button.
6. You can see a class is created. Double click on your class.

7. Remove all the default code by using (Ctrl+A + backspace) and be ready to do programming
in BlueJ.
I. To Write Comment (Single Line Comment and Multi-Line Comment)
• For Single Line Comment use “//*”
• For Multi-Line Comment use “/*”

II. Before start doing programming, we have to identify our class which provide blueprint
to our objects and to create specific objects within a program. Class simply identify
one or more objects.
III. First step to start programming is to write common syntax used while doing
programming (i.e. public static void main String args[] ). This is the most common and
important syntax used in blueJ while doing programming. Without this syntax we
cannot do programming in BlueJ.

public static void main should be in small letters whereas String first letter ’S’ should be in
capital letter. (String args []) should be inside the parentheses ‘()’ as shown in figure
above.
Let’s take an example; Write a program to print your name.

System.out.println is the statement which print the argument passed to it. For Eg: In the
above figure “My name is Anjal Mahato” is a argument which passes to the system and
println() method displays result in screen. The argument should write inside the
parentheses ‘()’ as shown in above figure. Note that semicolon ‘;’ is important after the
end of each statement. Curly bracket should use before and after the statement in main
method.
8. To print your name, first you have to compile your file.

You can see (Class compiled- no syntax error) in end of the screen, it means there is no
error in this programming. It is ready to run and print the result. If there is syntax error
then class will be not compiled and system will be not ready to print your statement.
Therefore, you have to be very careful about syntax.

9. After the class compiled, go back to the class where you created your class
10. Then right click on the class. Click on the ‘void main (String[]args)’.

11. Click on ‘OK’ button.


12. As we are writing our name so we can see our name printed on the screen.

We can conclude that the statement written inside the System.out.println() will be
shown the result printed in the screen.

This is the complete steps/procedure to run Java Program in BlueJ.

You might also like