23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

((Place) usa).pr<strong>in</strong>tMe();<br />

}<br />

}<br />

class State extends Region {<br />

State() { /* null constructor */ }<br />

public void pr<strong>in</strong>tMe() { System.out.pr<strong>in</strong>tln("Ship<br />

it."); }<br />

}<br />

class Region extends Place {<br />

Region() { /* null constructor */ }<br />

}<br />

public void pr<strong>in</strong>tMe() { System.out.pr<strong>in</strong>tln("Box it.");<br />

}<br />

class Place extends Object {<br />

Place() { /* null constructor */ }<br />

}<br />

public void pr<strong>in</strong>tMe() { System.out.pr<strong>in</strong>tln("Buy it.");<br />

}<br />

What is the output from call<strong>in</strong>g the ma<strong>in</strong>() method of the Maryl<strong>and</strong> class?<br />

R-2.12<br />

Write a short <strong>Java</strong> method that counts the number of vowels <strong>in</strong> a given character<br />

str<strong>in</strong>g.<br />

R-2.13<br />

Write a short <strong>Java</strong> method that removes all the punctuation from a str<strong>in</strong>g s<br />

stor<strong>in</strong>g a sentence. For example, this operation would transform the str<strong>in</strong>g<br />

"Let's try, Mike." to "Lets try Mike".<br />

R-2.14<br />

133

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!