0% found this document useful (0 votes)
5K views1 page

WJ 1102A Module2 Exercise 2

The document describes an exercise to create and manipulate String objects in Java. It instructs the reader to create a PersonTwo class with two String variables - one to store a quotation and the other to store the name of the person who said it. The class should include a displayQuote method to output the quotation and name. It then tells the reader to compile and test the class using a PersonTwoTest class.

Uploaded by

Rajani Ramsagar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5K views1 page

WJ 1102A Module2 Exercise 2

The document describes an exercise to create and manipulate String objects in Java. It instructs the reader to create a PersonTwo class with two String variables - one to store a quotation and the other to store the name of the person who said it. The class should include a displayQuote method to output the quotation and name. It then tells the reader to compile and test the class using a PersonTwoTest class.

Uploaded by

Rajani Ramsagar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercise 3: Using the String Class

The objective of this exercise is to create and initialize String objects and
to print their contents.

Task 1 – Creating and Manipulating String Objects


In this task, you write a class called PersonTwo that creates and initializes two
String variables and displays their values. Follow these steps to create your class:

1. Go to the object_structure directory.

2. Create a class called PersonTwo that creates and initializes two variables:

• The first variable stores a quotation.

• The second variable stores the name of the person who said it.

3. Use a method called displayQuote to display the quotation and the name to the
screen.

4. Compile your class.

5. Execute your class using the supplied PersonTwoTest class.

You might also like