Chapter 20 (Web site template) Java Utilities Package and Bit Manipulation

Chapter 20 Java Utilities Package and Bit Manipulation 1197 nextLong method of class Random removeElementAt method of class Vector NoSuchElementException class search method of class Stack NullPointerException seed of a random-number generator or method of class BitSet set method of class BitSet peek method of class Stack setElementAt method of class Vector persistent hash table setSeed method of class Random pop method of class Stack setSize method of class Vector Properties class size method of class Dictionary propertyNamesmethod of Properties size method of class Vector pseudorandom numbers Stack class push method of class Stack store method of class Properties put method of class Dictionary trimToSize method of class Vector Random class Vector class remove method of class Dictionary white-space characters removeAllElementsmethod of Vector xor method of class BitSet removeElement method of class Vector SELF-REVIEW EXERCISES 20.1 Fill in the blanks in each of the following statements: a) Java class provides the capabilities of array-like data structures that can re- size themselves dynamically. b) If you do not specify a capacity increment, the system will the size of the Vector each time additional capacity is needed. c) If storage is at a premium, use the method of the Vector class to trim a Vector to its exact size. 20.2 State whether each of the following is true or false. If false, explain why. a) Values of primitive data types may be stored directly in a Vector. b) With hashing, as the load factor increases, the chance of collisions decreases. 20.3 Under what circumstances is an EmptyStackExceptionthrown? 20.4 Fill in the blanks in each of the following statements: a) Bits in the result of an expression using operator are set to 1 if the corresponding bits in each operand are set to 1. Otherwise, the bits are set to zero. b) Bits in the result of an expression using operator are set to 1 if at least one of the corresponding bits in either operand is set to 1. Otherwise, the bits are set to zero. c) Bits in the result of an expression using operator are set to 1 if exactly one of the corresponding bits in either operand is set to 1. Otherwise, the bits are set to zero. d) The bitwise AND operator (&) is often used to bits, that is, to select certain bits from a bit string while zeroing others. e) The operator is used to shift the bits of a value to the left. f) The operator shifts the bits of a value to the right with sign extension, and the operator shifts the bits of a value to the right with zero extension. ANSWERS TO SELF-REVIEW EXERCISES 20.1 a) Vector. b) double. c) trimToSize. 20.2 a) False; a Vector stores only Objects. A program must use the type-wrapper classes (Byte, Short, Integer, Long, Float, Double, Boolean and Character) from package java.lang to create Objects containing the primitive data type values. b) False; as the load fac
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

Leave a Reply