index []khalid/pgjc2e/pgjc2_ix.pdf · 604 index arrays (continued) collection operations 434...

20
Index Symbols " 25 ' 23 * 128 . 126 ... 212, 214 /* and */ 26 /** and */ 27 // 26 ; 114 \ 24 {} 114, 123 ' 23 Numerics 2's complement 598 A absolute values 402 abstract classes 134 collection implementations 485 interfaces 135 methods 147 abstraction 2, 10 access order 449, 450 accessibility 7, 16, 120 anonymous classes 311 classes 131 default 131, 141 local classes 304 members 120, 133, 137 modifiers 131 non-static member classes 294 package 131 private 142 protected 139 public 131, 138 static member classes 289 UML 137 actual parameter list 86, 263 adding to class 226 additive operators 56 aggregation 10, 12, 229 hierarchy 229 aliases 5, 69 see also references analyzing program code 492 and 70, 76 anonymous arrays 104 collection implementations 481 anonymous classes 308 event listeners 308 Apostrophe 24 appending elements 441 application 15 architect exam 489 arguments to main method 38 ArithmeticException 187 array creation expression 104 array initializer block 104 array list 442 array of arrays 100, 106 array operations 434 ArrayIndexOutOfBoundsException 103, 187 arrays 100, 388 anonymous 104

Upload: others

Post on 24-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

Index

Symbols" 25' 23* 128. 126... 212, 214/* and */ 26/** and */ 27// 26; 114\ 24{} 114, 123' 23

Numerics2's complement 598

Aabsolute values 402abstract

classes 134collection implementations 485interfaces 135methods 147

abstraction 2, 10access order 449, 450accessibility 7, 16, 120

anonymous classes 311classes 131default 131, 141local classes 304members 120, 133, 137modifiers 131

non-static member classes 294package 131private 142protected 139public 131, 138static member classes 289UML 137

actual parameter list 86, 263adding to class 226additive operators 56aggregation 10, 12, 229

hierarchy 229aliases 5, 69

see also referencesanalyzing program code 492and 70, 76anonymous

arrays 104collection implementations 481

anonymous classes 308event listeners 308

Apostrophe 24appending elements 441application 15architect exam 489arguments to main method 38ArithmeticException 187array creation expression 104array initializer block 104array list 442array of arrays 100, 106array operations 434ArrayIndexOutOfBoundsException 103, 187arrays 100, 388

anonymous 104

Page 2: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

604 INDEX

arrays (Continued)collection operations 434declarations 100default initialization 101dynamic 442elements 100, 103initialization 101, 102, 106length 100objects 388reference 100, 103, 259

ArrayStoreException 260ASCII 23, 29assert statement 209

see assertions 209AssertionError 209, 210

see also assertions 209assertions 208, 307

assert statement 208compiling 211conditional compilation 218control flow invariants 217enabling and disabling 212internal invariants 216postconditions 218preconditions 218using 215

assignable 262assignment compatible 262assignments

bitwise 78cascading 48compound operators 59, 71, 78expression statement 48implicit narrowing 49multiple 48numeric conversions 48operator 42, 47primitive values 47references 47

associativity 43asynchronous 351attributes see propertiesautomatic garbage collection 6, 318automatic variables see local variablesAWTException 187

BBackslash 24Backspace 24

bags 437balanced tree 431base 22, 394, 398base class 226basic collection operations 433basic map operations 447binary

numbers 593numeric promotion 46operators 42search 482shift operators 79

binary numbers 593bit patterns 598bit shifting 79bitwise

and 76assignment 78not 76operators 75or 76shifting 79xor 76

blank final variable 94, 146blocked for I/O state 367blocked for join completion state 367blocked for lock acquisition state 367blocks 114, 123

catch 190finally 190, 195scope 123try 189

Boolean wrapper class 400booleans 28, 30

casting 44expressions 66literals 23

break statement 163, 164, 172BS see Backspacebuckets 471building abstractions 10bulk map operations 448bulk operations on collections 433byte 22, 28byte code 15

CC 148C++ 148

Page 3: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 605

call-by-reference 91call-by-value 91callee 86caller 86carriage return 24, 25cascading assignments 48cascading if-else statements 161case labels 161, 162case-sensitivity 20cast

44cast operator 42casting 44

downcasting 232upcasting 230see also conversions

catch block 190catch-and-throw paradigm 181catching exceptions 181ceil method 402certification 489, 561chaining

constructors 248finalizers 325new operator 297

char 29character set

ASCII 23, 29ISO Latin-1 23, 29Unicode 23, 29

character strings 407Character wrapper class 399characters 29

literals 23searching for 414

checked exceptions 187, 201child class 226child threads 351, 355choosing between String and StringBuffer

class 420Class class 389class file 15class lock 360, 364class method 10class variable 10ClassCastException 187, 265classes

abstract 134accessibility 131, 284adding to 226

anonymous 308as members 284base 226child 226constructors 117, 243declaration context 284definitions 2, 5, 37, 111derived 226diagram 8, 9extending 135, 226file name 289final 135generalized 228grouping 126header 111initialization 337, 345inner 284instance members 112instances 4local 302members 6methods 144modifiers 134mother of all 388name 117, 126nested see nested classesnon-static member 284, 292Object 388on-the-fly 284parent 226runtime 389scope 121specialized 228static 284static member 287static members 112subclass 10, 226superclass 10, 226top-level 37, 284variables 144wrappers 388, 392

ClassLoader class 388cleaning up 321clean-up code 195client 15Cloneable interface 389cloning objects 389code optimizations 146code reuse 226, 278Collection interface 429

Page 4: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

606 INDEX

collections 264, 428, 429abstract implementations 485anonymous implementations 481array operations 434ArrayList 442basic operations 433, 447bulk operations 433, 448Cloneable 430customizing 481data structures 431duplicate elements 437, 440elements 428empty constants 483filling 484first element 456HashMap 449HashSet 437Hashtable 449immutability 481implementations 428, 429, 431interfaces 428iterators 434last element 456LinkedList 442List 442lists 440Map 447, 449map views 448optional operations 432ordered 440range-views 441, 456retaining elements 433Serializable 430shuffle elements 484, 485singleton set 483SortedMap 452SortedSet 452, 456sorting 482subset 456textual representation 440thread-safety 442, 449, 481TreeMap 457TreeSet 457unsupported operations 447utility methods 428Vector 442views 442, 448, 456

collections framework 428Collections utility class 482command

java 17javac 16

comments 26common memory space 350communication 7, 86Comparable interface 453

compareTo 476comparable objects 452comparator 452Comparator interface

compare 452comparing objects 389, 453

see also equalitycomparison 67compilation unit 127complete methods 146composite object 10compound assignment operators 59compound statement 114concatenation of strings 413concatenation operator 62concurrent activities 350conditional 66

and 72expressions 83, 158operators 72, 83or 72statements 158

conditions 66connecting punctuation 20const 21constant declarations 251constant values 21, 146constants 255constituent objects 10constituents 12constructing loops 167constructor chaining 244, 248, 342constructors 3, 117, 243

chaining 244, 248default 118implicit default 118name 117overloading 120

constructs 20high-level 20loops see iteration statementssynchronized blocks 363, 364

context switching 350continue statement 174

Page 5: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 607

contract 2, 252, 253, 275, 278contracting lists 441control flow

break see break statementcontinue 174do-while 168for 169if 158if-else 160iteration see iteration statementsloops see iteration statementsreturn 176statements 113, 158switch 161throw 199transfer statements 171while 167

control flow invariants 217control transfer 171conversions 44

contexts 44, 46identity 60implicit narrowing 60narrowing 44number systems 594, 596numeric promotions 45parameter passing 263parameters 87reference casting 264references 268string concatenation 62to strings 416, 440truncation 49type safe 263unsafe casts 265widening 44

converting number systems 594, 596core interfaces 428counter-controlled loops 169CR see Carriage returncrab 171creating

objects 4, 84threads 351

currency symbol 20current object 114cursor 442

Ddaemon threads 351dangling references 318

data structures 431data types see typesdate 453dead state 367deadlocks 381declarations

arrays 84, 100local 114statements 113variables see variable declarations

declaring see declarationsdecorating collections 481decorators 481decoupling 273decrement operator 63deep copying 389default

accessibility 131, 137, 141constructor 118exception handler 184label 162values 33, 332, 342

defining see definitionsdefinitions

classes 37, 111inheritance 255interfaces 37, 251main method 38methods 112packages 36, 127

degrees 404delegating requests 278derived class 226destroying objects 324destructive collection operations 433developer exam 489, 495diagrams

class 3see also UML

dictionary 429dictionary order 412difference 437disjunct collections 440disposal of resources 321distance of shift 79division

floating-point 55integer 54

division operator/ 54

documentation 26documentation comment 26

Page 6: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

608 INDEX

documenting see documentationdot 126double 22, 29do-while statement 168downcasting 45, 232duplicate elements 437, 440duplicating objects 389dynamic method binding 231dynamic method lookup 231, 239, 273dynamically resizable arrays 442

Eelements 100, 428elements of collections 428eligible for garbage collection 319else clause matching 161empty collections 483empty set 437empty statement 114encapsulation 126, 275, 285encapsulation of implementation 278enclosing class 284, 292enclosing context 289, 291, 295entering shared resource 360entries 429, 447entry set 447EOFException 187equality 67, 389

equals method 69, 389object value 69objects 69primitive values 67references 68

equals method 69, 389equivalence relation 465equivalent collections 440Error 210escape sequences 24evaluation order 43

arithmetic expressions 51evaluation short-circuits 73event listeners

anonymous classes 308exam 489exam voucher 490Exception class 187exception handler 181

see also exceptions

exceptions 181, 188ArrayIndexOutOfBoundsException 103ArrayStoreException 260checked see checked exceptionsClassCastException 265default handler 184handler 181ignored 324IllegalThreadStateException 351IndexOutOfBoundsException 441NumberFormatException 394throw 199throwing see throwing exceptionsthrown by method 113types 185uncaught 184unchecked 187UnsupportedOperationException 432

exchanging information 86execution paths 350exiting a shared resource 360explicit

conversions 232garbage collection 327referencing 304

exponent 22exponential functions 404expression statements 48, 114expressions 162

boolean 66case labels 162conditional 83deterministic evaluation 42label 162return 176statements 114

extendingclasses 226interfaces 254Thread 355

extends clause 226interfaces 251

extensions.class 15.java 15

external libraries 336extracting substrings 416

Page 7: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 609

Ffactory methods 481fall through 162false literal 23FF see Form feedfield initialization 342fields 2

hiding 236see member variables

file 453file name 37, 289filling collections 484final

classes 135members 146parameters 94

finalization mechanism 319finalize method 324finalize method 389finalizer 324finalizer chaining 325finally block 190, 195first element 456float 22, 29floating-point 28

double 29float 29literals 22

floating-point arithmetic 52strictfp 54

floating-point division 55floating-point remainder 56floor method 403flow control see control flowfor statement 169foreign methods 148form feed 24, 25formal parameters 86, 113, 117, 123, 263formatting 26fractional signed numbers 28framework for collections 428fully qualified names 126, 256

package 127

Ggain lock ownership 360general abstractions 228general loops 169

generalization 10generalized classes 228generic data types 264goto 21, 171grammar rules 20grouping 126groups of objects 428GUI applications 351

Hhandles see referenceshas-a relationship 229hash codes 388hash function 471hash map 449hash table 431, 449hash value 471Hashing 471HashSet 437head map view 456head set view 456heap 318hexadecimal numbers 593hiding internals 275Horizontal tab 24HT see Horizontal tab

Iidentifiers 20

predefined 20reserved 20variable 31

identity conversion 60identity of object 5IEEE 754-1985 29if-else statement 160ignored exceptions 324illegal thread state 351IllegalArgumentException 187immediate superclass 246immediately enclosing instance 284immutable collections 481implementation 2implementation inheritance 226implementations 228, 275

collections 428inheritance hierarchy 135

implementations of collections 429

Page 8: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

610 INDEX

implementinginterfaces 253

implements clause 253implicit

default constructor 118inheritance 226narrowing conversions 60

importdeclaration 128single type import 128statement 37, 289type import on demand 128

increment expression 169increment operator 63independent lifetimes 229index 100index bounds 441IndexOutOfBoundsException 441individual array elements 103inequality 68

see also equalityinfinite loop 171infinity 52

negative 52positive 52

inheritance 10, 229hierarchy 228, 297

initial capacity 450initial state of object 342initialization

arrays 102, 106code 102default values 33for statement 169object references 32objects 5variables 31

initializer expressions 331initializers 331

declaration-before-read rule 332initializing see initializationinner classes 284

synchronization 364insertion order 438, 450instance

members 10, 112methods 10, 113, 114variable initialization 33variables 10, 32see also object

instance initializer block 338instance methods 6instance variables 6, 342instanceof operator 84, 264instantiation 4, 135

anonymous classes 311local classes 305non-static member classes 292static member classes 287

int 22, 28integer arithmetic 52integer division 54integer remainder operation 55integers 28

and 76byte 28data types 29int 28literals 22long 28not 76or 76representation 598short 28types 29xor 76

Integral types 28integrity (maintaining) 360interface-based 430interfaces 251

abstract 135accessibility 131body 251collection core 428definitions 37extending 254header 251implementing 310initialization 345top-level 37, 284variables 255

internal invariants 216interpreter 16intersection 437invoking garbage collection 327IOException 187is-a relationship 228, 229, 278ISO Latin-1 23, 29iteration statements 167

next iteration 174termination 167, 173

Page 9: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 611

iterators 434fail-fast 436

JJAR 130Java

interpreter 38Native Interface see JNIprogram 15

java 17-disableassertions or -da 212-disablesystemassertions or -dsa 215-enableassertions or -ea 212-enablesystemassertions or -esa 215

Java 2 SDK 16Java byte code 15Java compiler 16Java Native Interface see JNIJava Virtual Machine see JVMjavac 16

-source 1.4 211javadoc comment 26javadoc utility 26JNI 148joining threads 368JVM 16

Kkey insertion order 449key objects 429key sets 447key sorting 456keys 447keywords 20

abstract 134, 147assert 209boolean 30byte 28case 161catch 190char 29class 111, 112, 251const 21continue 174default 162do 168double 29

else 160extends 226final 94, 135, 146finally 195float 29for 169if 158implements 253import 128, 289instanceof 84, 264int 28interface 251long 28native 148new see new operatornull 264package 127private 142protected 139public 138reserved words 21return 176short 28static 16, 287, 336strictfp 54super 235, 238, 246switch 161synchronized 147, 360this 114throw 199throws 201transient 149try 189unused words 21void 16, 393volatile 150while 167, 168

Llabeled break statement 173labels 171, 173

break 173case 161default 162expressions 162labeled statement 171switch statement 161

last element 456least significant bit 598

Page 10: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

612 INDEX

leftassociativity 43shift 79

left-most bit 598legal assignments 262length method 410lexical tokens 20LF see Linefeedlibraries 336line terminator 25linear implementation inheritance 228Linefeed 24LinkageError 187linked list 442list 429lists 429, 440, 442

iterators 442literals 21

boolean 23character 23default type 22double 22escape sequences 24false 23float 22floating-point 22integer 22null 21predefined 21prefix 22, 594quoting 23scientific notation 22string 25suffix 22true 23

live threads 368load factor 438, 450local 34

chaining of constructors 244, 342classes 302declarations 114variables 33, 123

locale 413locks

class 359object 359

logarithm 404logical

and 70or 70

xor 70logical AND

& 70logical complement

! 70logical exclusive OR

^ 70logical inclusive OR

| 70logical XOR

^ 70long 22, 28

suffix 22loop condition 167loops see iteration statements

Mmagnitude 48main method 16, 17, 38main thread 351maintaining integrity 360manifest constant 19, 146manifest file

See JAR utility 130many-to-one relation 447map 429map views 448mappings 429

See entries 429maps 447, 449

access order 449entries 429key insertion order 449mappings 429ordering mode 449

marker interfaces 251Math class 116, 401math constants 402mathematical set 437MAX_VALUE constant 397maximum value 402member declarations 112, 251members 3, 120

access 114accessibility 133, 137classes 284default values 33final 146inheritance 226

Page 11: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 613

instance 112interfaces 284modified 226modifiers 144of objects 6scope 120short-hand 115static 7, 112, 144terminology 10

memory management 318message

passing 86receiver 7

method call 7, 86, 113chaining 423

method overloading 116, 237resolution 237

method overriding 231, 233, 237, 343method prototype 147, 252method prototype declaration 251, 252method signature 113, 233methods 3

abstract 147accessibility 113automatic variables see local variablesbody 113, 123call see method callchained 414clone 389definition 87, 112dynamic binding 231dynamic lookup 231, 273equals 69, 389exceptions 113finalize 324, 389foreign 148getClass 389header 112implementation 147invocation see method calllocal variablesmain see main methodmutually exclusive 363name 86native 148objects 114overloading see method overloadingparameters 113prototypes 252return 176return value 113

signature 113, 116, 237synchronized 147, 360termination 176throws clause 201toString 389valueOf 416

MIN_VALUE constant 397minimizing overhead 321minimum value 402modifiers

abstract 134, 147accessibility 131, 137classes 134final 146main method 38native 148static 144strictfp 54synchronized 147transient 149volatile 150

most significant bit 598mother of all classes 388multiple assignments 48multiple implementation inheritance 251multiple interface inheritance 251multiple-line comment 26multiplication operator

* 54multiplicative operators 54multisets 437multitasking 350multithreaded programming 350mutable character strings 420mutex

See locks 359mutually exclusive

actions 160locks 359operations 360

Nname 20named constants 146namespaces 117NaN 53narrowing conversions 44

primitive 45reference 45

native libraries 336

Page 12: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

614 INDEX

native methods 148natural logarithms 402, 404natural order 452, 453, 482negative zero 53nested classes 284

anonymous 308full name 288local 302non-static member 292static member 287synchronization 364

new operator 4, 101, 117, 297, 308, 342special form 293

Newline see LinefeedNL see Newlinenon-associativity 42non-runnable states 367nonstatic code

See nonstatic context 112nonstatic context 112non-static field 10non-static member classes

full name 288not 76notifying threads 370, 371, 390null reference 21

casting 44, 264NullPointerException 187Number class 396number systems

base 22binary 594converting 594, 596decimal 22, 594hexadecimal 22, 594octal 22, 594

NumberFormatException 187, 394numeric promotions 45

assignment 48binary 46unary 45

numeric wrapper classes 396

Oobject 4Object class 228, 388object lock

See locks 359object references 4

object state 6, 91, 117, 342object-oriented programming 2objects 13

alive 319arrays 100callee 86caller 86Class class 389cleaning up 321cloning 389communication 86comparing 389, 453composite 319constituent 12, 319constructing 342contract 275create 4decoupling 273destroying 324equality 69, 389exchanging information 86identity 5immutable 392implementation 275initial state 342initialization 5, 117initializer block 338internals 275members 6methods 114Object class 388outer 294persistent 149reachable 319resurrection 319services 275state see object statevalue equality 69

octal numbers 593one-dimensional arrays 100on-the-fly classes 284OOP 2open range-view operations 441operands 44

evaluation order 43operations 2operators 42

- 56-- 63! 70

Page 13: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 615

!= 67, 68% 54, 55%= 59& 70, 75&& 72&= 71, 78* 51, 54*= 59+ 56, 62++ 63+= 59. 7, 126/ 54/= 59< 67<< 79, 80<<= 83<= 67-= 59= 47== 67, 68> 67>= 67>> 79, 81>>= 83>>> 79>>> 82>>>= 83? : 83^ 70, 75^= 71, 78| 70, 75|= 71, 78|| 72~ 75assignment 42, 47associativity 42binary 42bitwise 75, 79boolean 67, 70cast 42comparisons 67compound assignment 59, 71, 78conditional 72, 83decrement 63dot 7equality 67execution order 43floating-point 52floating-point division 55

floating-point remainder 56increment 63instanceof 84, 264integer 75integer arithmetic 52integer division 54integer remainder 55logical 70multiplicative 54new see new operatoroverflow 52overloaded 52, 54postfix 42precedence 42relational 67shift 79short-circuited 72string concatenation 62ternary 42unary 42, 54unary - 54unary + 54

optional operations 432or 70, 76ordered collections 429, 440ordering mode 449out of bounds 441outer object 294overflow 52, 598overloaded 52overloading

constructors 120methods 116, 237resolution 237

override 203overriding

equals 69, 461finalizers 324hashCode 471methods 231, 233, 237toString 62

Ppackage accessibility 131, 137package statement 36, 127packages 126

accessibility see package accessibilitydefinition 36, 127hierarchy 126

Page 14: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

616 INDEX

packages (Continued)java.lang 388java.util 428members 126naming scheme 127short-hand 128statement see package statementunnamed 128using 128

parameter list see formal parametersparameters 113

actual 86array elements 92arrays 91conversions on passing 263final 94formal see formal parametersimplicit 114passing 86primitives 88references 89this 114

parent class 226parentheses 42parseType method 398parsing numeric values 397, 398partial implementation 253partly synchronizing a method 363passing

messages 86parameters 86references 89

paths of execution 350permute elements 484, 485persistent objects 149polymorphism 231, 259, 272, 279, 305positive zero 53postconditions 218, 307postfix operators 42power 404precedence rules 43precision 48preconditions 218predefined identifiers 20predefined literals 21preempted threads 369preemptive scheduling 369prefix 22, 594

0 22, 5940x 22, 594

primitive types 13see also primitive values

primitive valuesassignment 47equality 67passing 88

priorities 368priority of thread 368private 11private members 142process-based multitasking 350processes 350program

application 15compiling 16formatting 26running 17

programmer exam 489promotion 45properties 2

see also class membersprotected 11protected members 139prototypes of methods 252pseudorandom number 405public 16public members 138

Qquestions 492quotation mark 24, 25quote ’ 23

Rrace condition 361radians 404radix

See base 394raised to power 404random number 405random order 484, 485range

character values 29floating-point values 29integer values 28

range-view 441, 442, 456Ready-to-run state 367reclaiming memory 318

Page 15: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 617

reducing complexity 275reference

downcasting 45narrowing conversions 45upcasting 45widening conversions 45

reference objects 320reference type 32reference values 4reference variable 4, 31references 4, 5, 9, 13, 32, 86

abstract types 134aliases 69array 100, 103, 259assignment 47casting 44, 264converting 268dangling 318equality 68null see null referencepassing 89reachable 318, 319strong 320super 238, 304this 114, 304

referent 320relational operators 67remainder operator

% 55remove white space 416replacing characters 415reserved identifiers 20reserved keywords 21

const 21goto 171

reserved literalsfalse 23null see null referencetrue 23

resizable arrays 442resources 321resurrecting objects 319retaining elements 433return statement 176return value 7reuse of code 226, 278rhyming order 454right associativity 43right-most bit 598ripple effect 278role relationship 278

round method 403rounding functions 402rounding numbers 403Round-Robin scheduling 369Runnable interface 351, 356running out of memory 321Running state 367runtime checks 44Runtime class 388runtime class 389runtime environment 318runtime stack 318RuntimeException 187

Sschedulers 369scientific notation 22scope 120

block 123catch block 194class 121

search key 462searching 428searching for elements 482searching in string 414SecurityManager class 388selection statements 158semantic definition 20semicolon 114sequence 429services 275set 429shallow copying 389shared resource 359shift

distance 79left 79operators 79

shifting 79short 22, 28short-circuit 72

evaluation 73shuffle elements 484, 485sign fill 79signature 116, 237signed shift 79simple

assignment operator 47if 158statement 114

Page 16: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

618 INDEX

single implementation inheritance 228, 251, 254

single-line comment 26single-quotes 23singleton set 483single-valued maps 447skeletal source file 36sleeping 370Sleeping state 367, 370sleeping state 367sorted map 429, 452sorted set 429, 452, 456sorting 428, 482source

file 15, 127file name 37file structure 36

spaces 25spawning threads 351special character values 24specialization 10specialized classes 228square root 404stack 3stack trace 184starting threads 352state see object statestatements 113

assert 209break 172compound 114conditional 158continue 174control flow 113, 158control transfer 171declarations 113do-while 168empty 114expression 114for 169if 158if-else 160iteration 167labeled 171return 176selection 158simple 114simple if 158switch 161throw 199

transfer 171while 167

staticinitializer block 336members see static membersmethods 7, 10, 113variable initialization 33variables see static variables

static codeSee static context 112

static context 112static factory methods 481static field 10static initializer 218static keyword 336static member classes 287

full name 288static members 7static members 9, 10, 112static variables 7, 10, 33storing objects 149strictfp 54string buffer 63

capacity 420constructing 421

String class 407string literals 407

interned 407StringBuffer class 420strings 407

appending 422buffers 420capacity 424changing case 413charAt 410compareTo 412comparing 412, 453concat 413concatenation 62, 413concatenation operator + 63, 414constructing 421creating 407deleting 422equals 412extracting substrings 416getChars 410ignoring case in comparison 412indexOf 415individual characters 410, 421initializing 407

Page 17: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 619

inserting 422length 410, 421lexicographical order 412literals 25mutable 420natural order 453replacing 415searching 414substrings 416trim 416

strong references 320strongly typed language 44subclass 10, 11, 12, 226subinterface 254sublist 442submap view 456subpackage 126subset 437, 440, 456substring searching 414substrings 414, 416subtype 254suffix

D 22F 22L 22

Sun Educational Services 490super

construct 246keyword 235, 238reference 238

super keyword 246superclass 10, 11, 226superclass–subclass relationship 228superinterfaces 254superset 440supertypes 254switch

break 163, 164statement 161

switching between threads 350Sylvan Prometric 490synchronization 351, 359synchronized

blocks 363, 364keyword 360methods 147, 360

syntactically legal 20System class 388system classes 213, 215

TTAB see Horizontal tabtabs 25tabulators 25tail map view 456tail set view 456technology architect exam 489telephone directory order 412terminating loops 172ternary conditional operator 42testing locations 491textual representation 389this

reference 114special form 295

this() constructor call 243, 342thread 318

live 318termination 380

Thread class 351thread creation 351thread of execution 350thread safety 350thread-based multitasking 350ThreadDeath 187threads 388

alive 351, 368blocked 360Blocked for I/O state 367Blocked for join completion state 367Blocked for lock acquisition state 367child 351, 355class 351code executed 352creation 351daemon 351dead state 367death 184extending Thread 355IllegalThreadStateException 351implemented by inner classes 358joining 368main 351names 353non-runnable state 367notification 370, 372notifying 371, 390priorities 368Ready-to-run state 367

Page 18: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

620 INDEX

threads (Continued)Runnable 351, 356running 355Running state 367scheduler 368sleeping 370Sleeping state 367, 370sleeping state 367spawning 351starting 352, 355states 366status 351switching 350synchronization 147, 359synchronized 360Thread class 351transitions 366user 351waiting for notification state 367yielding 369

thread-safe 420thread-safe collections 481throw statement 199Throwable class 185, 388throwing exceptions 181throws clause 201time-sliced scheduling 369tokens 20top level

classes 131toString method 389, 395total order 452transfer flow

assert 209transfer statements 171transient variables 149tree map 457tree set 457trees 431trigonometry functions 404trim 416true literal 23truth-values 23, 30try block 189try-catch-finally construct 188type hierarchy 258type safe 263types

boolean 28, 30byte 22, 28

casting 44char 29classes see classescompatibility 44conversion 44double 29exceptions 185float 29floating-point 28, 29generic 264int 22, 28integers 28, 29integral types 28long 22, 28parsing 397, 398short 22, 28wrappers 392see also classes

UUML 2

accessibility 137aggregation 12classes 3inheritance 11see also diagrams

unary numeric promotion 45unary operators 42uncaught exceptions 184unchangeable variables 146unchecked exceptions 187underflow 53, 598Unicode 23, 29Unified Modeling Language see UMLunion 437unsafe casts 265unsupported operations 432, 447unused keywords 21upcasting 45, 230user threads 351using packages 128using variables 31

Vvalue collection 447value objects 429valueOf method 394, 416values 447, 598

Page 19: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization

INDEX 621

constants 21conversion 44overflow 598underflow 598wrap-around 598see also variables

variable declarations 4, 31, 123variable initialization 8, 34variables 31

blank final 94, 146constant values 146declarations see variable declarationsdefault values 33final 146identifiers 31in interfaces 255initialization see variable initializationlifetime 32local 123object reference 32parameters 86, 113references 32static 7storing 149transient 149volatile 150

vector 442Venn diagrams 433view of list 442VirtualMachineError 187void 176, 393Void wrapper class 393

volatile variables 150voucher 490

Wwait set 371waiting for conditions 371waiting for notification state 367while statement 167white space 25, 416whole–part relationship 229widening conversions 44

primitive 44reference 45

wrapper classes 28, 388, 392, 453wrapping collections 481

Xxor 70, 76

Yyielding 369

Zzero

negative 53positive 53

zero fill shift 79

Page 20: Index []khalid/pgjc2e/PGJC2_IX.pdf · 604 INDEX arrays (Continued) collection operations 434 declarations 100 default initialization 101 dynamic 442 elements 100, 103 initialization