Appendix

About

This section is included to assist the students to perform the activities in the book.

It includes detailed steps that are to be performed by the students to achieve the objectives of the activities.

Lesson 1: Introduction to Java

Activity 1: Printing the Results of Simple Arithmetic Operations

Solution:

  1. Create a class named Operations as follows:

    public class Operations

    {

  2. Within main(), print a sentence describing the operation on the values you will be performing along with the result:

    public static void main(String[] args) {

    System.out.println("The sum of 3 + 4 is " + (3 + 4));

    System.out.println("The product of 3 + 4 is " + (3 * 4));

    }

    }

    The output will be as follows:

    The sum of 3 + 4 is 7

    The product of 3 + 4 is 12

Get Java Fundamentals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.