Experiment 2: Characters and Character Strings


One of the simple expressions in the output statement is '+' and another is " = ". In the first case, the plus symbol is surrounded by single-quotes and in the second case, the double-quotes surround a blank, an equal symbol and another blank. In Java, the '+' is called a character expression, while the " = " is called a String expression.

A. In the space below, form a hypothesis that explains when characters should be surrounded with single-quotes (') and when they should be surrounded with double-quotes ("). Don't worry about your hypothesis being wrong -- if so, it's finding out why it is wrong that is important.





B. Next, in the space below, design an experiment to test your hypothesis. This part you should worry about -- if your hypothesis is wrong, then your experiment must tell you so.












C. Then carry out your experiment, and report its results in the space below:













D. If your hypothesis was shown to be incorrect, repeat steps A through C, until your hypothesis and experimental results agree. In the space below, explain why '+' is called a character expression and " = " is called a String expression.







When you understand the difference between ' and " (in Java), continue to the next experiment.


Back to the Exercise List

Forward to the Next Experiment



Back to the Table of Contents

Back to the Introduction


Copyright 2000 by Prentice Hall. All rights reserved.