Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CSIII – Unit 2 Exam Page 1 VOCABULARY LIST Term Definition 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. class Blueprint to make object object Instance of a class reference Variable storing the address of an object constructor Special method invoked to create an object initialize To give an initial value to a variable immutable Not changeable index Numerical position of a character in a String object instantiate To create an object new Java operator used to make an object null A reserved word indicating a reference refers to no object. package a. Group of classes in the Java API import keyword used to specify a class(es) used in a program method Things an object can do static reserved word indicating a method can be invoked using Class name instead of an object KEY CONCEPTS CREATING OBJECTS o You create (“instantiate”) objects using the new operator o The variable used to refer to your object is known as a “reference variable”/remote control o You can have more than one variable referring to the same object (aliases) STRINGS o The characters in a string object are numbered starting at zero (index) o String objects have several methods you can use on them substring(int start, int end) - start is inclusive, end is not (return part of the string) length() – return length of string replace (char oldChar,newChar) – replace one char with another char PACKAGES o All classes in the Java bible (API) are contained in a package o The java.lang package is automatically imported into your program o You must import classes you wish to use in your program (except ones from java.lang) RANDOM CLASS o Code to create a random generator: Random generator = new Random( ) o nextInt(num) – returns an integer from 0 (inclusive) to the num specified (exclusive) o nextFloat( ) – returns a decimal value from 0 to 1.0 (exclusive) MATH CLASS o Has several static methods you can use (invoke as Math.____) o Examples: Math.pow(2,5) = 32 Math.sqrt(16) = 4 FORMATTING OUTPUT o 2 classes can be used (NumberFormat, DecimalFormat) o DecimalFormat you specify format using # 0 $ , % (0 – means show zero in your answer) WRAPPER CLASSES o Use these to create objects for the primitive data types. There is one wrapper for each primitive type o Wrappers: Integer, Double, Float, Character, Boolean, Long, Short