Chap03 EX Solutions

Chap03 EX Solutions - Java Software Solutions, 6th Edition...

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

View Full Document Right Arrow Icon
Java Software Solutions, 6 th Edition Exercise Solutions, Ch. 3 Chapter 3 Exercise Solutions EX 3.1. Write a statement that prints the number of characters in a String object called overview . System.out.println (overview.length()); EX 3.2. Write a statement that prints the 8 th character of a String object called introduction . System.out.println (introduction.charAt(7)); EX 3.3. Write a declaration for a String variable called change and initialize it to the characters stored in another String object called original with all 'e' characters changed to 'j' . String change = original.replace ('e', 'j'); EX 3.4. 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’. EX 3.5.
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 07/26/2011 for the course COP 2551 taught by Professor Roggio,r during the Summer '08 term at UNF.

Page1 / 2

Chap03 EX Solutions - Java Software Solutions, 6th Edition...

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