BlueJ Lab Exercises: Java Programming Fundamentals, Exercises of Java Programming

A series of exercises for learning Java programming basics using BlueJ IDE. Topics covered include installing BlueJ, creating a new project, writing and running a method, printing statements, and understanding variable declarations and assignments.

Typology: Exercises

2019/2020

Uploaded on 01/11/2020

samia-khan-2
samia-khan-2 🇵🇸

4.8

(4)

11 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
LAB 01: BlueJ
EXERCISE 01:
1. Install BlueJ on PC.
Figure 1
2. Create a new project in BlueJ, name it LAB1.
Figure 2
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download BlueJ Lab Exercises: Java Programming Fundamentals and more Exercises Java Programming in PDF only on Docsity!

LAB 01: BlueJ

EXERCISE 01:

  1. Install BlueJ on PC. Figure 1
  2. Create a new project in BlueJ, name it LAB1. Figure 2
  1. Create a class in that project called MyFirstLab Figure 3
  2. Write a method in that class called printStuff
  3. In printStuff , print a line like this but use your own name Hi! My name is Bruno Mars Figure 4

OUTPUT:

Figure 7

EXERCISE: 03

  1. Add a println statement that prints the sum of the numbers 8355 and 429
  2. Add a println statement that multiplies the numbers 34 and 17 and prints the result
  3. The multiplication operator in Java is * Figure 8

OUTPUT:

Figure 9

EXERCISE :

  1. Add a println statement that prints the following sentence on one line:
  2. This is a pretty long sentence if you ask me not that you asked me but if you did I'd say it was.
  3. We want to keep each line of code relatively short (easier to read).
  4. But you can't split a character string across two lines of code! Try it.
  5. Instead, split the string up into separate strings and concatenate them together.

Figure 12 OUTPUT: Figure 13

EXERCISE:

  1. Add a block comment to your program above the class: **/**** *** This is my program for Lab 1.
  • @author your-pid-here
  • @version 2018.01. /*
  1. If you type /** and hit return it will add the * automatically.
  2. Add another comment above the method: /**** *** This method helps me practice printing. */

Figure 14

EXERCISE:

  1. A variable is the name given to a memory location in which a value is stored.
  2. The variable's type must be declared before it is used. It can also be given a value in the declaration: int total = 54; System.out.println("The total is " + total);
  3. Change the value with an assignment statement: total = 75;
  4. Print the value of total again.