CHAPTER 3 - Java Software Solutions, 4e Lewis and Loftus...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Software Solutions, 4e Lewis and Loftus Chapter 3 Exercise Solutions 3.1. What output is produced by the following code fragment? String m1, m2, m3; m1 = "Quest for the Holy Grail"; m2 = m1.toLowerCase(); m3 = m1 + " " + m2; System.out.println (m3.replace('h', 'z')); The output produced is: Quest for tze Holy Grail quest for tze zoly grail The original string is concatenated with a lowercase version of itself, then all lowercase ‘h’ characters are replaced with ‘z’. 3.2. Write an assignment statement that computes the square root of the sum of num1 and num2 and assigns the result to num3 . num3 = Math.sqrt(num1 + num2); 3.3. Write a single statement that computes and prints the absolute value of total . System.out.println (Math.abs(total)); 3.4. What is the effect of the following import statement? import java.awt.*; This statement allows all the classes in the java.awt package to be referenced in a program without the explicit package name.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 2

CHAPTER 3 - Java Software Solutions, 4e Lewis and Loftus...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online