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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

public static void ma<strong>in</strong>(Str<strong>in</strong>g[] args) {<br />

Pair[] a = new Pair[10]; // right, but<br />

gives a warn<strong>in</strong>g<br />

Pair[] b = new<br />

Pair[10]; // wrong<br />

a[0] = new Pair(); // this is<br />

completely right<br />

a[0].set("Dog",10); // this <strong>and</strong> the next statement are<br />

right too<br />

System.out.pr<strong>in</strong>tln("First pair is "+a[0].getKey()+",<br />

"+a[0].getValue());<br />

}<br />

2.6 Exercises<br />

For source code <strong>and</strong> help with exercises, please visit<br />

java.datastructures.net.<br />

Re<strong>in</strong>forcement<br />

R-2.1<br />

Can two <strong>in</strong>terfaces extend each other? Why or why not?<br />

R-2.2<br />

Give three examples of life-critical software applications.<br />

R-2.3<br />

Give an example of a software application where adaptability can mean the<br />

difference between a prolonged sales lifetime <strong>and</strong> bankruptcy.<br />

R-2.4<br />

Describe a component from a text-editor GUI (other than an "edit" menu) <strong>and</strong><br />

the methods that it encapsulates.<br />

R-2.5<br />

Draw a class <strong>in</strong>heritance diagram for the follow<strong>in</strong>g set of classes:<br />

130

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

Saved successfully!

Ooh no, something went wrong!