Oracle press OCA OCP JavaSE 7 programmer i II study guide

1.1K 1.3K 0
Oracle press OCA OCP JavaSE 7 programmer i II study guide

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Join the Oracle Press Community at OraclePressBooks.com Find the latest information on Oracle products and technologies Get exclusive discounts on Oracle Press books Interact with expert Oracle Press authors and other Oracle Press Community members Read blog posts, download content and multimedia, and so much more Join today! Join the Oracle Press Community today and get these benefits: • Exclusive members-only discounts and offers • Full access to all the features on the site: sample chapters, free code and downloads, author blogs, podcasts, videos, and more • Interact with authors and Oracle enthusiasts • Follow your favorite authors and topics and receive updates • Newsletter packed with exclusive offers and discounts, sneak previews, and author podcasts and interviews @OraclePress ® OCA/OCP Java SE Programmer I & II Study Guide ® (Exams 1Z0-803 & 1Z0-804) This page intentionally left blank ® OCA/OCP Java SE Programmer I & II Study Guide ® (Exams 1Z0-803 & 1Z0-804) Kathy Sierra Bert Bates McGraw-Hill Education is an independent entity from Oracle Corporation and is not affiliated with Oracle Corporation in any manner This publication and digital content may be used in assisting students to prepare for the OCA Java SE Programmer I and OCP Java SE Programmer II exams Neither Oracle Corporation nor McGraw-Hill Education warrants that use of this publication and digital content will ensure passing the relevant exam Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective owners New York Chicago San Francisco Athens London Madrid Mexico City Milan New Delhi Singapore Sydney Toronto Copyright © 2015 by McGraw-Hill Education (Publisher) All rights reserved Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication ISBN: 978-0-07-177199-3 MHID: 0-07-177199-9 The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-177200-6, MHID: 0-07-177200-6 eBook conversion by codeMantra Version 1.0 All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps McGraw-Hill Education eBooks are available at special quantity discounts to use as premiums and sales promotions or for use in corporate training programs To contact a representative, please visit the Contact Us page at www.mhprofessional.com Oracle and Java are registered trademarks of Oracle Corporation and/or its affiliates All other trademarks are the property of their respective owners, and McGraw-Hill Education makes no claim of ownership by the mention of products that contain these marks Screen displays of copyrighted Oracle software programs have been reproduced herein with the permission of Oracle Corporation and/or its affiliates Information has been obtained by Publisher from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, Publisher, or others, Publisher does not guarantee to the accuracy, adequacy, or completeness of any information included in this work and is not responsible for any errors or omissions or the results obtained from the use of such information Oracle Corporation does not make any representations or warranties as to the accuracy, adequacy, or completeness of any information contained in this Work, and is not responsible for any errors or omissions TERMS OF USE This is a copyrighted work and McGraw-Hill Education and its licensors reserve all rights in and to the work Use of this work is subject to these terms Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill Education’s prior consent You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited Your right to use the work may be terminated if you fail to comply with these terms THE WORK IS PROVIDED “AS IS.” McGRAW-HILL EDUCATION AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill Education and its licensors not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill Education nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom McGraw-Hill Education has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill Education and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise CONTRIBUTORS Kathy Sierra was a lead developer for the SCJP exam for Java and Java Kathy worked as a Sun “master trainer,” and in 1997, founded JavaRanch.com, the world’s largest Java community website Her bestselling Java books have won multiple Software Development Magazine awards, and she is a founding member of Oracle’s Java Champions program These days, Kathy is developing advanced training programs in a variety of domains (from horsemanship to computer programming), but the thread that ties all of her projects together is helping learners reduce cognitive load Bert Bates was a lead developer for many of Sun’s Java certification exams, including the SCJP for Java and Java Bert was also one of the lead developers for Oracle’s OCA and OCP exams He is a forum moderator on JavaRanch.com and has been developing software for more than 30 years (argh!) Bert is the co-author of several bestselling Java books, and he’s a founding member of Oracle’s Java Champions program Now that the book is done, Bert plans to go whack a few tennis balls around and once again start riding his beautiful Icelandic horse, Eyrraros fra Gufudal-Fremri About the Technical Review Team This is the fourth edition of the book that we’ve cooked up The first version we worked on was for Java Then we updated the book for the SCJP 5, again for the SCJP 6, and now for the OCA and OCP exams Every step of the way, we were unbelievably fortunate to have fantastic, JavaRanch.com-centric technical review teams at our sides Over the course of the last 12 years, we’ve been “evolving” the book more than rewriting it Many sections from our original work on the Java book are still intact On the following pages, we’d like to acknowledge the members of the various technical review teams who have saved our bacon over the years About the Java Technical Review Team Johannes de Jong has been the leader of our technical review teams forever and ever (He has more patience than any three people we know.) For the Java book, he led our biggest team ever Our sincere thanks go out to the following volunteers who were knowledgeable, diligent, patient, and picky, picky, picky! Rob Ross, Nicholas Cheung, Jane Griscti, Ilja Preuss, Vincent Brabant, Kudret Serin, Bill Seipel, Jing Yi, Ginu Jacob George, Radiya, LuAnn Mazza, Anshu Mishra, Anandhi Navaneethakrishnan, Didier Varon, Mary McCartney, Harsha Pherwani, Abhishek Misra, and Suman Das This page intentionally left blank About the SCJP Technical Review Team Andrew Burk Devender Bill M Jeoren Jef Jim Gian Kristin Marcelo Marilyn Johannes Mark Mikalai Seema Valentin We don’t know who burned the most midnight oil, but we can (and did) count everybody’s edits— so in order of most edits made, we proudly present our Superstars Our top honors go to Kristin Stromberg—every time you see a semicolon used correctly, tip your hat to Kristin Next up is Burk Hufnagel who fixed more code than we care to admit Bill Mietelski and Gian Franco Casula caught every kind of error we threw at them— awesome job, guys! Devender Thareja made sure we didn’t use too much slang, and Mark Spritzler kept the humor coming Mikalai Zaikin and Seema Manivannan made great catches every step of the way, and Marilyn de Queiroz and Valentin Crettaz both put in another stellar performance (saving our butts yet again) Marcelo Ortega, Jef Cumps (another veteran), Andrew Monkhouse, and Jeroen Sterken rounded out our crew of Superstars—thanks to you all Jim Yingst was a member of the Sun exam creation team, and he helped us write and review some of the twistier questions in the book (bwa-ha-ha-ha) As always, every time you read a clean page, thank our reviewers, and if you catch an error, it’s most certainly because your authors messed up And oh, one last thanks to Johannes You rule, dude! About the SCJP Technical Review Team Fred Marc P Mikalai Christophe Since the upgrade to the Java exam was like a small, surgical strike we decided that the technical review team for this update to the book needed to be similarly fashioned To that end we handpicked an elite crew of Marc W JavaRanch’s top gurus to perform the review for the Java exam Our endless gratitude goes to Mikalai Zaikin Mikalai played a huge role in the Java book, and he returned to help us out again for this Java edition We need to thank Volha, Anastasia, and Daria for letting us borrow Mikalai His comments and edits helped us make huge improvements to the book Thanks, Mikalai! Marc Peabody gets special kudos for helping us out on a double header! In addition to helping us with Sun’s new SCWCD exam, Marc pitched in with a great set of edits for this book—you saved our bacon this winter, Marc! (BTW, we didn’t learn until late in the game that Marc, Bryan Basham, and Bert all share a passion for ultimate Frisbee!) Like several of our reviewers, not only does Fred Rosenberger volunteer copious amounts of his time moderating at JavaRanch, he also found time to help us out with this book Stacey and Olivia, you have our thanks for loaning us Fred for a while Marc Weber moderates at some of JavaRanch’s busiest forums Marc knows his stuff, and uncovered some really sneaky problems that were buried in the book While we really appreciate Marc’s help, we need to warn you all to watch out—he’s got a Phaser! Finally, we send our thanks to Christophe Verre—if we can find him It appears that Christophe performs his JavaRanch moderation duties from various locations around the globe, including France, Wales, and most recently Tokyo On more than one occasion Christophe protected us from our own lack of organization Thanks for your patience, Christophe! It’s important to know that these guys all donated their reviewer honorariums to JavaRanch! The JavaRanch community is in your debt Index registering JDBC drivers, 856–858 regular expressions (regex) vs globs, 522 metacharacters, 434–436 pattern matching, 443–446 quantifiers, 437–442 ranges, 437 simple searches, 432–434 strings, 442–443 tokenizing See tokenizing regular inner classes, 685–686 Relational Database Management Systems (RDBMSs), 843 relational operators, 226–227 equality, 227–232 key points, 247 relative() method, 883–885 relative paths, 495 relativizing paths, 505–506 releaseSavepoint() method, 927 releasing locks, 744 reluctant quantifiers, 440–441 remainder operator, 235–236 remove() method ArrayList, 293–294 BlockingQueue, 802 collections, 590, 801 lists, 628 maps, 628 sets, 628 removeFirst() method, 751, 753 removing ArrayList elements, 293–294 renameTo() method, 489–490 renaming files and directories, 525 replace() method collections, 801 strings, 267 replace operations, 445 replaceAll() method, 445 replacing string elements, 267 reports, printing, 878–880 reset() method, 525 resolve() method, 504 resolving paths, 503–504 resource bundles, 454–456 default locales, 458 Java, 457–458 key points, 465 property, 456–457 selecting, 459–461 ResourceBundle class, 455–456 resources autocloseable, 396–401 closing, 903–906 results, database, 845–846 See also ResultSets ResultSet interface, 851–852, 915 ResultSetMetaData class, 876 ResultSets cursor types, 881 information about, 876–878, 896–900 key points, 932–933 moving in, 869–870, 880–889 overview, 868 reading from, 870–875 reports, 878–880 RowSet objects, 913–915 updating, 889–896 resume() method, 730 rethrowing exceptions, 353, 392–396 retrieving path information, 500–501 return statement in for loops, 326 return type constructors, 49, 126, 128 declarations, 122–125 key points, 151 overloaded methods, 106, 122–123 overridden methods, 103, 123–124 returning values, 124–125 reuse composition, 549 inheritance for, 89 names, 197–198 reuseless code, 682 reverse() method arrays, 627 collections, 627 strings, 272 979 980 OCA/OCP Java SE Programmer I & II Study Guide reverseOrder() method arrays, 627 collections, 627 reversing strings, 272 ride.in property, 460 roll() method, 424 rollback() method, 924–925 rolling back transactions, 924–926 rowChanged() method, 918 rowDeleted() method, 893 rows database, 842–843 inserting, 894–896 RowSet interface, 913 rowSetChanged() method, 918 RowSetEvent class, 918 RowSetFactory interface, 913–914 RowSetListener interface, 915, 918 RowSetProvider class, 913–914 RowSetReader interface, 920 RowSets, 913 connected, 916–919 disconnected, 919–920 key points, 934 overview, 913–914 working with, 914–915 RowSetWriter interface, 920 rowUpdated() method, 891 rs.getObject() method, 880 rules constructors, 128–129 expression, 381–382 source file, 10–11 run() method class source, 764 overriding, 717 threads, 716, 721–722, 726 Runnable interface executing, 806 implementing, 718 I/O activities, 814 threads, 716, 764 runnable thread state, 729 running thread state description, 729 threads, 728 running with assertions, 384 runtime disabling assertions at, 384–386 enabling, 384 Runtime class available processors, 811 garbage collection, 205 runtime exceptions for overridden methods, 103 RuntimeException class, 343, 348–351 S s in format strings, 453 \s in searches, 435 savepoints for transactions, 922, 926–927 Scanner class searching with, 445–446 tokenizing with, 449–450 scheduled thread pools, 812 ScheduledThreadPoolExecutor, 812 scheduler, thread, 727–728 schema, database, 847–850 scope in for loops, 327 key points, 209 variables, 182–185 searches, 432 arrays and collections, 611–613 boundary matching, 436 character matching, 435 files, 490–491 key points, 664 metacharacters, 434–435, 442–443 pattern matching, 443–446 quantifiers, 437–442 ranges, 437 Scanner class, 445–446 simple, 432–434 strings, 442–443 TreeSets and TreeMaps, 620–621 Index SELECT operation description, 845–846 SELECT * FROM, 861 SELECT with WHERE, 845 semicolons (;) abstract methods, 22, 43–44 anonymous inner classes, 693–694 enums, 62 in for loops, 324 labels, 332 native methods, 47 while loops, 323 separation of concerns principle, 805 serialization of transient variables, 586–587 setAttribute() method, 512–513 setAutoCommit() method, 925 setConcurrency() method, 916 setEscapeProcessing() method, 916 setLastModified() method, 508 setMaxFieldSize() method, 916 setMaximumFractionDigits() method, 430 setMaxRows() method, 916 setName() method, 727 setParseIntegerOnly() method, 430 setPosixFilePermissions() method, 513 setPriority() method key points, 735, 766 threads, 728 setQueryTimeout() method, 916 sets and Set interface, 589 description, 591 methods, 626, 628 overview, 594–595, 616–617 in searches, 437 sets of characters in globs, 521 setString() method, 909 setters encapsulation, 85 setTime() method, 422 setTimes() method, 510, 513 setTransactionIsolation() method, 916, 926 setType() method, 916 setUrl() method, 915 shadowed variables, 55, 183, 197–198 short-circuit logical operators, 242–244, 312 short type case constants, 314 default values, 186 ranges, 51 wrappers, 602 shutdown of ExecutorService, 814–815 shutdownNow() method, 815 side effects from assertions, 389 signalAll() method, 795 signatures of methods, 112, 117 signed numbers, 51 simple searches, 432–434 SimpleFileVisitor class, 515–516 single quotes (') in PreparedStatements, 909 single thread pools, 812 singleton design pattern benefits, 554 description, 549–550 key points, 566 problem, 550–551 solution, 551–554 size ArrayLists, 293–294 arrays, 57, 274, 276, 280, 282, 284 assignment issues, 225 numbers, 51 size() method ArrayLists, 293–294 collections, 590, 800 lists, 616, 628 maps, 628 sets, 628 SKIP_SIBLINGS result type, 518 SKIP_SUBTREE result type, 518 slashes (/) compound assignment operators, 225–226 division, 235 globs, 520–521 sleep() method class source, 764 key points, 766 locks, 749 overview, 731–733 threads, 716, 728, 736 working with, 733–734 981 982 OCA/OCP Java SE Programmer I & II Study Guide sleeping thread state, 734 description, 729–730 overview, 731–733 sort() method arrays, 627 collections, 604–606, 627 sorted collections, 591–593 SortedMap interface, 589 SortedSet interface, 589 sorting arrays, 610, 627 collections, 604–611, 627 Comparable interface, 606–608 Comparator interface, 608–609 key points, 664 source code file declaration rules, 10–11, 69 spaces natural ordering, 628 searches, 435 special-purpose queues, 803 special relationships in inner classes, 684, 699 split() method, 447–448 spontaneous wakeup, 763 spreadsheets See databases SQL (Structured Query Language), 843–844 closing resources, 903–906 injection attacks, 866 queries, 845–847 types, 871 SQLException class driver classes, 856 PreparedStatements, 909 ResultSets, 887, 894 RowSets, 917 stored procedures, 912 SQLWarning class, 902 square brackets ([]) array elements, 56–57 arrays, 274 searches, 437 stack exceptions, 356 key points, 209 local variables, 54 methods, 339–340 overview, 166–167 threads, 807 StackOverflowError class description, 358 recursive methods, 356 StandardWatchEventsKinds class, 524 start() method alternative, 806 class source, 764 threads, 716, 720, 724–726 starting threads, 714–716, 720–727 transaction contexts, 922–924 Statement interface, 851–852, 863, 907 statements constructing and using, 864–867 databases, 844 description, 863 states description, key points, 765–766 threads, 728–731 static constants, 27 static fields, synchronizing, 750 static imports, 15–17 static initialization blocks, 139 static nested classes, 682 key points, 703 overview, 699–700 static variables and methods, 15, 59–60, 140 constructors, 129 description, 183 inner classes, 689, 692 key points, 73, 153 locks, 748 overriding, 103, 146 overview, 141–146 synchronizing, 746–747 stop() method, 730 stored procedures CallableStatements, 910–912 information about, 899 Index invoking, 865 transactions, 923 stream classes, 480 strictfp modifiers classes, 20 inner classes, 689 methods, 47–48 String class, 258–264 constant pool, 264 key points, 296 methods, 265–268 object references, 192–193 String.split() method, 447–448 String URL property, 915 StringBuffer class, 258 vs StringBuilder, 269–270 thread safeness, 751 StringBuilder class, 258 key points, 296 methods, 271–272 overview, 269 vs StringBuffer, 269–270 thread safeness, 751 StringIndexOutOfBoundsException class, 344–345 strings, 258 appending, 259–260, 270–271 case constants, 314 comparing, 266–267 concatenating, 236–238, 248, 266 converting to URIs, 496 creating, 265 deleting, 271 equality, 230–231, 316–317 format, 452–454 immutability, 258–264 inserting elements into, 272 key points, 296 length, 267 literals, 172, 264 lower case, 268 memory, 264–265 methods, 265–268 replacing elements in, 267 reversing, 272 983 searches, 442–443 substrings, 267–268 trimming, 268 upper case, 268 StringTokenizer class, 450–451 Structured Query Language (SQL), 843–844 closing resources, 903–906 injection attacks, 866 queries, 845–847 types, 871 subclasses anonymous inner classes, 696 concrete, 44–46 inheritance, subdirectories, 515–519 subdividing tasks, 816–817 subMap() method, 622–624 submitting queries, 861–867 subpath() method, 500 subSet() method, 623–624 subsets in searches, 445 substring() method, 267–268 subtraction compound assignment, 225–226 operator, 235 subtypes for reference variables, 96 SUNDAY field, 424 super() calls for constructors, 137–138 super constructor arguments, 132–134 superclasses, constructors, 129 overridden methods, 104–105 supportsANSI92EntryLevelSQL() method, 897, 900 supportsSavePoints() method, 927 suppressed exceptions, 401–402 suspend() method, 730 switch statements, 313–314 break and fall-through, 317–319 default case, 319–320 exercise, 320–321 key points, 361 legal expressions, 314–316 string equality, 316–317 symmetry of equals(), 581 984 OCA/OCP Java SE Programmer I & II Study Guide synchronization blocks, 745–748 code, 738–744 key points, 767 locks, 744–747 methods, 47, 744–745 need for, 749–751 static methods, 746–747 synchronizedList() method, 751–753, 798 SynchronousQueue class, 801, 803 SyncProvider class, 920 System.exit() method loops, 326 threads, 815 try and catch, 360 System.gc() method, 204–206 System.out.println() method, 448 system resources for threads, 807 T \t escape sequence, 443 tables See databases tabs, 443 tailMap() method, 623–624 tailSet() method, 623–624 take() method BlockingQueue, 802 LinkedTransferQueue, 803 WatchService, 525 tasks CPU-intensive vs I/O-intensive, 807–808 decoupling from threads, 809–811 subdividing, 816–817 TERMINATE result type, 518 ternary operator conditional, 240–241 key points, 248 test database overview, 847–850 this() calls for constructors, 129, 137–138 this keyword, 56, 688–689 Thomas, Dave, 923 Thread class, 714, 716–717 extending, 717–718 methods, 728, 764 Thread.currentThread().isInterrupted() method, 815 Thread.interrupt() method, 815 thread-safe classes, 751–753 thread-safe collections, 800 thread-safe patterns, 553 ThreadLocalRandom class, 814 ThreadPoolExecutor, 812 ThreadPools, 805–806 cached, 811 fixed, 811 key points, 831 scheduled, 812 single, 812 threads blocked code, 748–749 concurrency See concurrency creating and putting to sleep, 733–734 deadlocks, 753–754 decoupling from tasks, 809–811 defining, 714–718 exercise, 747–748 garbage collector, 201 instantiating, 714–716, 718–720 interaction, 755–760 key points, 765–768 limits, 807 locks, 748–749 making, 716–717 multiple, 724–727 names, 722 notifyAll(), 760–764 preventing execution, 731 priorities, 734–738 scheduler, 727–728 sleeping state, 731–734 starting, 714–716, 720–727 states and transitions, 728–731 synchronization and locks, 744–747 synchronization need, 749–751 synchronization of code, 738–744 thread-safe classes, 751–753 threads of execution, 714, 718, 720 three-dimensional arrays, 57, 274 Throwable class, 343 Index thrown exceptions description, 335 JVM, 355–356 programmatically, 356–357 tightly coupled classes, 543 TIME data type, 875 time-slicing scheduler, 734 TIMESTAMP data type, 875 toArray() method lists, 613–614, 628 sets, 616, 628 tokenizing, 446 delimiters, 446–447 key points, 464–465 Scanner, 449–450 split(), 447–448 StringTokenizer, 450–451 toLowerCase() method, 268 top-level nested classes, 682 toString() method ArrayLists, 291 arrays, 627 null tests, 880 objects, 893 overview, 575–576 Path, 500 String, 268 StringBuilder, 272 toUpperCase() method, 268 transactions concepts, 922 contexts, 922–924 demarcation, 924 key points, 934 overview, 921–922 rolling back, 924–926 savepoints, 926–927 transfer() method, 803 transient variables overview, 58 serialization, 586–587 transitions with threads, 728–731 transitivity of equals(), 581 tree structures, 501, 595 985 TreeMap class, 589 navigating, 620–622 overview, 596 TreeSet class, 589 creating, 616 methods, 623 navigating, 620–622 overview, 595 trim() method, 268 true value, 171 truncating from casts, 179 try and catch feature file I/O, 482 finally, 336–339, 389–392 key points, 405 multi-catch clauses, 389–392 overview, 335–336 try-with-resources feature autocloseable resources with, 396–401, 405 working with, 905–906 tryLock() method, 791–793 two-dimensional arrays, 57, 274 two's complement notation and casts, 179 TYPE_FORWARD_ONLY cursor type, 880–881, 902 type-safe arrays, 629 TYPE_SCROLL_INSENSITIVE cursor type, 881–882, 891 TYPE_SCROLL_SENSITIVE cursor type, 881, 902 types array declarations, 274 assignments, 225 casting See casts erasure, 637 parameters, 631–632 return See return type variables, 173 U \u prefix, 171 UML (Unified Modeling Language), 95, 553 unassigned variables key points, 210 working with, 185–188 986 OCA/OCP Java SE Programmer I & II Study Guide unboxing problems, 639 uncaught exceptions, 339–342 unchecked exceptions description, 350 overridden methods, 103 underscores (_) in numeric literals, 168–169 Unicode characters char type, 52 identifiers, literals, 171 strings, 258 Unified Modeling Language (UML), 95, 553 uninitialized variables key points, 210 working with, 185–188 unions in searches, 437 unique Map keys, 595 unlabeled statements, 331 unordered collections, 591 unpredictabilty of threads, 725–726, 735 unsorted collections, 591–592 UnsupportedOperationException class, 799 unwinding the stack, 344 upcasting, 115 update() method, 558 UPDATE operation, 846 updateFloat() method, 890 updateObject() method, 893–894 updateRow() method, 890–891 updating nongeneric code to generic, 633 ResultSets, 889–896 SQL, 846 upper case natural ordering, 628 SQL commands, 846 strings, 268 URIs, converting strings to, 496 URLs, JDBC, 858–859 usernames, hard-coding, 855 V valueOf() method, 893 values() method, 64 values of variables, 172 var-args key points, 73 methods, 48–49 VARCHAR data type, 875 variable argument lists, 48–49 variables access See access and access modifiers assignments See assignments atomic, 786–789, 829 declarations, 50–52, 73 description, enums, 63–64 final, 58–59 in for loops, 327 heap and stack, 166–167 initializing, 175 inner classes, 691 instance, 52–53 local See local variables names, primitives, 50–52 scope, 182–185 shadow, 197–198 static, 59–60, 141–146 transient, 58 uninitialized and unassigned, 185–188, 210 values, 172 volatile, 58–59 Vector class, 589, 593–594 versions compiler, 383 JDBC drivers, 860–861 vertical bars (|) bitwise operators, 241–242 logical OR operator, 243–245 multi-catch clauses, 390 visibility, access, 18, 42 visitFile() method, 516–517 visitFileFailed() method, 517 Index void return type, 125 volatile variables, 58–59 W \w in searches, 435 wait() method class source, 764 description, 575 key points, 768 loops, 761–763 Object, 813 threads, 728, 755–760 waiting thread state, 729–730 walkFileTree() method, 515–516 warnings vs fails, 636 JDBC, 901–906 WatchKeys, 525 WatchService, 523–526 weakly consistent iterators, 800 WebRowSet, 919–920 WET programmers, 924 while loops labeled, 333 working with, 321–322 whitespace as default delimiter, 449–451 property resource bundles, 457 in searches, 435 tokens, 448 trimming from strings, 268 widening conversions, 176 width in format strings, 453 wildcards generics, 659 globs, 520–522 import statements, 14, 17 LIKE operator, 869 word boundaries in searches, 435–436 work stealing, 819–820 wrapper classes primitives, 182, 600–603 strings, 356 wrapping I/O classes, 484 write() method, 483 write permissions, 507, 512 Writer class, 486 writing attributes, 506–507 X XML, 871 XOR (exclusive-OR) operator hashcodes, 585 overview, 245 Xss1024k option, 807 Y yield() method class source, 764 key points, 767 locks, 749 overview, 734–738 threads, 716, 728 Z zero-based indexes, 12 zero-length matches, 445 0x prefix, 169 zeroes in format strings, 453 987 Join the Largest Tech Community in the World Download the latest software, tools, and developer templates Get exclusive access to hands-on trainings and workshops Grow your professional network through the Oracle ACE Program Publish your technical articles – and get paid to share your expertise Join the Oracle Technology Network Membership is free Visit oracle.com/technetwork @OracleOTN facebook.com/OracleTechnologyNetwork Copyright © 2014, Oracle and/or its affiliates All rights reserved Oracle and Java are registered trademarks of Oracle and/or its affiliates Need help? Need consultation? Need an informed opinion? Stay Connected You Need an Oracle ACE oracle.com/technetwork/oracleace Oracle partners, developers, and customers look to Oracle ACEs and Oracle ACE Directors for focused product expertise, systems and solutions discussion, and informed opinions on a wide range of data center implementations oracleaces @oracleace B blogs.oracle.com/oracleace Their credentials are strong as Oracle product and technology experts, community enthusiasts, and solutions advocates And now is a great time to learn more about this elite group—or nominate a worthy colleague For more information about the Oracle ACE program, go to: oracle.com/technetwork/oracleace Copyright © 2012, Oracle and/or its affiliates All rights reserved Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective owners 123022 Reach More than 700,000 Oracle Customers with Oracle Publishing Group Connect with the Audience that Matters Most to Your Business Oracle Magazine The Largest IT Publication in the World Circulation: 550,000 Audience: IT Managers, DBAs, Programmers, and Developers Profit Business Insight for Enterprise-Class Business Leaders to Help Them Build a Better Business Using Oracle Technology Circulation: 100,000 Audience: Top Executives and Line of Business Managers Java Magazine The Essential Source on Java Technology, the Java Programming Language, and Java-Based Applications Circulation: 125,000 and Growing Steady Audience: Corporate and Independent Java Developers, Programmers, and Architects For more information or to sign up for a FREE subscription: Scan the QR code to visit Oracle Publishing online Copyright © 2012, Oracle and/or its affiliates All rights reserved Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective owners 113940 Beta Test Oracle Software Get a first look at our newest products—and help perfect them You must meet the following criteria: Licensed Oracle customer or Oracle PartnerNetwork member Oracle software expert Early adopter of Oracle products Please apply at: pdpm.oracle.com/BPO/userprofile If your interests match upcoming activities, we’ll contact you Profiles are kept on file for 12 months Copyright © 2014, Oracle and/or its affiliates All rights reserved Oracle and Java are registered trademarks of Oracle and/or its affiliates LICENSE AGREEMENT THIS PRODUCT (THE “PRODUCT”) CONTAINS PROPRIETARY SOFTWARE, DATA AND INFORMATION (INCLUDING DOCUMENTATION) OWNED BY McGRAW-HILL EDUCATION AND ITS LICENSORS YOUR RIGHT TO USE THE PRODUCT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT LICENSE: Throughout this License Agreement, “you” shall mean either the individual or the entity whose agent opens this package You are granted a non-exclusive and non-transferable license to use the Product subject to the following terms: (i) If you have licensed a single user version of the Product, the Product may only be used on a single computer (i.e., a single CPU) If you licensed and paid the fee applicable to a local area network or wide area network version of the Product, you are subject to the terms of the following subparagraph (ii) (ii) If you have licensed a local area network version, you may use the Product on unlimited workstations located in one single building selected by you that is served by such local area network If you have licensed a wide area network version, you may use the Product on unlimited workstations located in multiple buildings on the same site selected by you that is served by such wide area network; provided, however, that any building will not be considered located in the same site if it is more than five (5) miles away from any building included in such site In addition, you may only use a local area or wide area network version of the Product on one single server If you wish to use the Product on more than one server, you must obtain written authorization from McGraw-Hill Education and pay additional fees (iii) You may make one copy of the Product for back-up purposes only and you must maintain an accurate record as to the location of the back-up at all times COPYRIGHT; RESTRICTIONS ON USE AND TRANSFER: All rights (including copyright) in and to the Product are owned by McGraw-Hill Education and its licensors You are the owner of the enclosed disc on which the Product is recorded You may not use, copy, decompile, disassemble, reverse engineer, modify, reproduce, create derivative works, transmit, distribute, sublicense, store in a database or retrieval system of any kind, rent or transfer the Product, or any portion thereof, in any form or by any means (including electronically or otherwise) except as expressly provided for in this License Agreement You must reproduce the copyright notices, trademark notices, legends and logos of McGraw-Hill Education and its licensors that appear on the Product on the back-up copy of the Product which you are permitted to make hereunder All rights in the Product not expressly granted herein are reserved by McGraw-Hill Education and its licensors TERM: This License Agreement is effective until terminated It will terminate if you fail to comply with any term or condition of this License Agreement Upon termination, you are obligated to return to McGraw-Hill Education the Product together with all copies thereof and to purge all copies of the Product included in any and all servers and computer facilities DISCLAIMER OF WARRANTY: THE PRODUCT AND THE BACK-UP COPY ARE LICENSED “AS IS.” McGRAW-HILL EDUCATION, ITS LICENSORS AND THE AUTHORS MAKE NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE RESULTS TO BE OBTAINED BY ANY PERSON OR ENTITY FROM USE OF THE PRODUCT, ANY INFORMATION OR DATA INCLUDED THEREIN AND/OR ANY TECHNICAL SUPPORT SERVICES PROVIDED HEREUNDER, IF ANY (“TECHNICAL SUPPORT SERVICES”) McGRAW-HILL EDUCATION, ITS LICENSORS AND THE AUTHORS MAKE NO EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE WITH RESPECT TO THE PRODUCT McGRAW-HILL EDUCATION, ITS LICENSORS, AND THE AUTHORS MAKE NO GUARANTEE THAT YOU WILL PASS ANY CERTIFICATION EXAM WHATSOEVER BY USING THIS PRODUCT NEITHER McGRAW-HILL EDUCATION, ANY OF ITS LICENSORS NOR THE AUTHORS WARRANT THAT THE FUNCTIONS CONTAINED IN THE PRODUCT WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE PRODUCT WILL BE UNINTERRUPTED OR ERROR FREE YOU ASSUME THE ENTIRE RISK WITH RESPECT TO THE QUALITY AND PERFORMANCE OF THE PRODUCT LIMITED WARRANTY FOR DISC: To the original licensee only, McGraw-Hill Education warrants that the enclosed disc on which the Product is recorded is free from defects in materials and workmanship under normal use and service for a period of ninety (90) days from the date of purchase In the event of a defect in the disc covered by the foregoing warranty, McGraw-Hill Education will replace the disc LIMITATION OF LIABILITY: NEITHER McGRAW-HILL EDUCATION, ITS LICENSORS NOR THE AUTHORS SHALL BE LIABLE FOR ANY INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS BUT NOT LIMITED TO, LOSS OF ANTICIPATED PROFITS OR BENEFITS, RESULTING FROM THE USE OR INABILITY TO USE THE PRODUCT EVEN IF ANY OF THEM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES THIS LIMITATION OF LIABILITY SHALL APPLY TO ANY CLAIM OR CAUSE WHATSOEVER WHETHER SUCH CLAIM OR CAUSE ARISES IN CONTRACT, TORT, OR OTHERWISE Some states not allow the exclusion or limitation of indirect, special or consequential damages, so the above limitation may not apply to you U.S GOVERNMENT RESTRICTED RIGHTS: Any software included in the Product is provided with restricted rights subject to subparagraphs (c), (1) and (2) of the Commercial Computer Software-Restricted Rights clause at 48 C.F.R 52.227-19 The terms of this Agreement applicable to the use of the data in the Product are those under which the data are generally made available to the general public by McGraw-Hill Education Except as provided herein, no reproduction, use, or disclosure rights are granted with respect to the data included in the Product and no right to modify or create derivative works from any such data is hereby granted GENERAL: This License Agreement constitutes the entire agreement between the parties relating to the Product The terms of any Purchase Order shall have no effect on the terms of this License Agreement Failure of McGraw-Hill Education to insist at any time on strict compliance with this License Agreement shall not constitute a waiver of any rights under this License Agreement This License Agreement shall be construed and governed in accordance with the laws of the State of New York If any provision of this License Agreement is held to be contrary to law, that provision will be enforced to the maximum extent permissible and the remaining provisions will remain in full force and effect

Ngày đăng: 12/05/2017, 14:49

Từ khóa liên quan

Mục lục

  • Cover

  • Title Page

  • Copyright Page

  • Contents

  • Contributors

  • Acknowledgments

  • Preface

  • Introduction

  • Part I: OCA and OCP

    • 1 Declarations and Access Control

      • Java Refresher

      • Identifiers and Keywords (OCA Objectives 1.2 and 2.1)

      • Define Classes (OCA Objectives 1.2, 1.3, 1.4, 6.6, and 7.6)

      • Use Interfaces (OCA Objective 7.6)

      • Declare Class Members (OCA Objectives 2.1, 2.2, 2.3, 2.4, 2.5, 4.1, 4.2, 6.2, and 6.6)

      • Declare and Use enums (OCA Objective 1.2 and OCP Objective 2.5)

      • 2 Object Orientation

        • Encapsulation (OCA Objectives 6.1 and 6.7)

        • Inheritance and Polymorphism (OCA Objectives 7.1, 7.2, and 7.3)

        • Polymorphism (OCA Objectives 7.2 and 7.3)

        • Overriding / Overloading (OCA Objectives 6.1, 6.3, 7.2, and 7.3)

        • Casting (OCA Objectives 7.3 and 7.4)

        • Implementing an Interface (OCA Objective 7.6)

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan