100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Exam (elaborations) TEST BANK Annotated Solution Guide for Thinking in Java 4th Edition By Bruce Eckel and Ervin Varga

Beoordeling
-
Verkocht
-
Pagina's
774
Geüpload op
11-11-2021
Geschreven in
2021/2022

Detailed instructions for installing, configuring and testing the source code. These instructions describe a Windows installation, but they will also act as a guide for OSX and Linux installations. These instructions also work with the free demo version of the guide. 1. Create a directory called C:TIJ4-Solutionscode. 2. Using WinZip or some other zip utility (if one is not preinstalled, search the web for a free utility), extract the zip file containing the code that you received when you purchased the guide. Unzip it into the C:TIJ4-Solutionscode directory. When you’re done, you should see numerous subdirectories in the C:TIJ4-Solutionscode directory, including subdirectories corresponding to the chapters in the solution guide. 3. Install the Java SE Development Kit (JDK), version 5 or newer, from the download site at Sun ( You’ll also eventually want the documentation, which is available from the same site. 4. Set the CLASSPATH in your computer’s environment. For Windows machines, right-click on the “My Computer” icon and select “Properties.” Then select the “Advanced” tab and click the “Environment Variables” button at the bottom. Under “System Variables,” look to see if there’s already a “CLASSPATH” variable. If there is, double click it and add ;.;..;C:TIJ4-Solutionscode; to the end of the current entry. If there is no “CLASSPATH” variable, click the “New” button and enter CLASSPATH In the “Variable name” box, and .;..;C:TIJ4-Solutionscode; In the “Variable value” box, then click “OK”. To verify that your classpath has been set, start a command prompt (see below), then enter set and look for the CLASSPATH information in the output. 5. Using the same technique as in Step 4, but for PATH instead of CLASSPATH, add the bin directory from your Java installation into your 2 Thinking in Java, 4th Edition Annotated Solution Guide system’s PATH environment variable. On Windows, the default JDK installation path is under “C:Program Files” and because this has spaces, you must quote that directory when adding it to the PATH: C:"Program Files"Javabin; 6. Create a directory called C:jars. Place the following files into this directory: • (download here: may need to search for it). • from the Eclipse SWT library ( recent build number, then scroll down to “SWT Binary and Source” and select the file corresponding to your platform. Further details about finding the jar file are in Thinking in Java, 4th Edition, under the heading “Installing SWT.” • , which is actually part of the JDK, but you must explicitly add it to your classpath. You’ll find it in the lib directory wherever you installed the JDK on your machine. (The default is C:"Program Files"Javalib). • , also part of the JDK, in the /jre/lib/ directory. • , available from 7. You must explicitly add each of the Jar files to your CLASSPATH, following the directions in Step 4. However, you must also include the name of the Jar file in the CLASSPATH entry. For example, after you put the file into the C:jars directory, the associated CLASSPATH entry is C:jars;. 8. Install the Ant 1.7 (or newer) build tool by following the instructions you will find in the Ant download at Note: Ant is required in order to compile the examples in the book. Once you successfully run ‘ant build’ in the root directory, you can also compile each example individually (once you have the CLASSPATH set, as described in Step 4) using the javac command-line compiler that was installed when you completed the steps 3 and 5. To compile a file called MyP, you type javac MyP. 9. Start a command prompt in the C:TIJ4- Solutionscode directory. To do this in Windows, press the “Start” button, then select “Run” and type “cmd” and press “OK.” then type Installing the Code 3 cd C:TIJ4-Solutionscode into the resulting command window. 10. At the prompt, type ant build The build should successfully compile all the chapters in the solution guide. 11. Once you’ve run ant build in the root directory, you can also move into individual chapters and type ant (to compile and execute the code in that chapter) or ant build (to compile the code only). 12. This code is designed to work without an IDE, but it has also been tested with Eclipse (free at for instructions on how to use the code with Eclipse. If you want to use this code inside other IDEs you might need to make appropriate adjustments. Different IDEs have different requirements and you might find it’s more trouble than it’s worth right now; instead, you may want to begin with a more basic editor like JEdit (free at 13. Note: The output for the programs has been verified for Java 6. Certain programs (primarily those that use hashing) can produce different output from one version to the next. Using Eclipse Once you’ve followed the above instructions, you can use the code inside the Eclipse development environment as follows: 1. Install Eclipse from for Java developers and follow the installation instructions. 2. Start Eclipse, then choose File | New | Java Project from the main menu. 3. In the ensuing dialog box, under “Contents,” select “Create Project from Existing Source.” Press the “Browse” button and navigate to C:TIJ4- Solutionscode. Enter “TIJ4-Solutions” as the project name and press the “Finish” button. Note: If you are installing the demo version of the solution guide, you do not need to perform any of the following steps. 4 Thinking in Java, 4th Edition Annotated Solution Guide 4. Eclipse will work for awhile and then present you with a “problems” pane containing a lot of errors and warnings. We’ll remove the errors in the following steps. 5. In the “Package Explorer” pane, right click on “TIJ4-Solutions” and select “Properties” (at the bottom). In the left column of the ensuing dialog box, select “Java Build Path.” 6. Select the “Source” tab. The default Eclipse configuration may have chosen to exclude and include some files. Click on “Included” and press the “Remove” button, then click on “Excluded” and press “Remove.” 7. Click on “Excluded” and press “Edit.” Under “Exclusion Patterns,” add the following files, which are not intended to compile. After you add the files, press the “Finish” button. • access/E04_ForeignC • arrays/E11_AutoboxingWithA • interfaces/E02_A • reusing/E06_ChessWithoutDefC • reusing/E20_OverrideA • reusing/E21_FinalM • reusing/E22_FinalC 8. Click on the “Libraries” tab, then the “Add External Jars” button. Add , , and that are described in step 6 of the previous section. 9. When you press OK to close the dialog box, the project should rebuild without any errors. The warnings that you see refer to code that is intentional for those solutions, in order to demonstrate features and issues of the language. 5 Packages & IDEs When Java first appeared there was no Integrated Development Environment (IDE) support, so you typically used a text editor and the command-line compiler. Over the years, IDE support has gotten so good (and many prevalent IDEs are free) that it’s less and less likely that you’ll develop in Java – or even learn the language – without an IDE. There’s a conflict, however, between IDEs and the way that Thinking in Java attempts to teach the language: One step at a time, using language features only after they’ve been introduced. An IDE like Eclipse (from www.E) likes to have all its code in packages (later versions have become more tolerant of unpackaged code, but it still prefers packages). Packages, however, are not introduced until the Access Control chapter. Because of the prevalence of IDEs, we have chosen to include package statements for all the code in this book, even for chapters before Access Control. If you have solved the problems in those chapters without using package statements, your solutions are still correct. 7 Left to the Reader We have left only a few exercises to the reader. For these, the solution typically requires some configuration on your own computer. The exercises left to the reader include: • Exercises 12 & 13 from the chapter Everything Is an Object • Exercise 13 from the chapter Initialization & Cleanup • Exercise 2 from the chapter Access Control • Exercise 15 from the chapter Generics • Exercise 8 from the chapter Arrays • Exercise 21 from the chapter Containers in Depth • Exercise 35, 36, 38, 39, and 43 from the chapter Graphical User Interfaces 9 Everything is an Object To satisfy IDEs like Eclipse, we have included package statements for chapters before Access Control. If you have solved the problems in this chapter without using package statements, your solutions are still correct. Exercise 1 //: object/E01_DefaultI /****************** Exercise 1 ***************** * Create a class containing an int and a char * that are not initialized. Print their values * to verify that Java performs default * initialization. ***********************************************/ package object; public class E01_DefaultInitialization { int i; char c; public E01_DefaultInitialization() { Sln("i = " + i); Sln("c = [" + c + ']'); } public static void main(String[] args) { new E01_DefaultInitialization(); } } /* Output: i = 0 c = [ ] *///:~ When you run the program you’ll see that both variables are given default values: 0 for the int, and a “space” for the char. Exercise 2 //: object/E02_HelloW 10 Thinking in Java, 4th Edition Annotated Solution Guide /****************** Exercise 2 ****************** * Follow the HelloD example in this * chapter to create a "hello, world" program that * simply displays that statement. You need only a * single method in your class (the "main" one that * executes when the program starts). Remember * to make it static and to include the argument * list (even though you don't use it). * Compile the program with javac and run it using * java. If you are using a different development * environment than the JDK, learn how to compile * and run programs in that environment. ************************************************/ package object; public class E02_HelloWorld { public static void main(String[] args) { Sln("Hello, world!"); } } /* Output: Hello, world! *///:~ Exercise 3 //: object/E03_ATypeN /****************** Exercise 3 ****************** * Turn the code fragments involving ATypeName * into a program that

Meer zien Lees minder











Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Documentinformatie

Geüpload op
11 november 2021
Aantal pagina's
774
Geschreven in
2021/2022
Type
Tentamen (uitwerkingen)
Bevat
Onbekend

Onderwerpen

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
GradeMaster1 Chamberlain School Of Nursing
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
85
Lid sinds
4 jaar
Aantal volgers
79
Documenten
1025
Laatst verkocht
8 maanden geleden
GradeMaster1

Unlocking the potential of minds, one subject at a time. We are a team of passionate tutors specializing in nursing, engineering, science, and education. With our knowledge and expertise, we guide students towards academic excellence and career success. Join us on this educational journey!

3.5

18 beoordelingen

5
6
4
3
3
6
2
0
1
3

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen