11910701430 | Array: .length, Arraylist: .size(), String: .length() | How do you find the lenghts of an Array, Arraylist, and String? | 0 | |
11910748833 | For loop, while loop, do-while loop, improved for loop/for each loop | name of different types of loops | 1 | |
11910763845 | ArrayList = easier to add and remove things; Array = difficult to add and remove things | What is one benefit of an ArrayList compared to an Array? | 2 | |
11910862710 | For each: for(int x: array) | What how would you write a for each loop filled with ints? | 3 | |
11918452974 | X: 0 Y: 1079 | What would the X and Y coordinates be for the bottom left pixel in a 1920x1080 picture? | 4 | |
11918486254 | They have a fixed size which can't change after initialization. | What is one limitation of arrays? | 5 | |
11930139054 | an int stores a number and is a primitive type a String stores an sequence of characters and is an object | What is the difference between an int and a String | 6 | |
11922065877 | For a user to denote the end of the data set but not part of the data set itself. Ex: Enter -1 to quit | What is one possible use of sentinel variables? | 7 | |
11922107338 | 1) have a loop that continues until the specific value or values are entered Ex: while (input != -1) 2) create a boolean set to false and have the loop run until a sentinel value is entered, in which case the boolean returns a true and the loop is broken Ex: while (!done) | What are two possible ways to implement a sentinel variable? | 8 | |
11929738875 | Boolean is easier to use for while loops, for loops allow initialization of variables and conditions, do loops check the condition at the end, so it goes through at least once. | What are the advantages a for each loop? | 9 | |
11929821195 | denotes the end of a data set, but it is not part of the data | define sentinel value | 10 | |
11929830958 | use == | How do you test if two object references (not values) are identical? | 11 | |
11931504632 | A break statement breaks out of a loop and any loop that it may be nested in. A continue statement will follow a condition and move to the next iteration of the loop. | What are the purposes of break and continue statements? | 12 | |
11938172078 | True | True or False: a constructor is a method that is automatically called when an object is created | 13 | |
11938604497 | Input validation is important as all data which is entered into the system needs to be validated in order to ensure that the program will run as intended. | Why is input validation important? | 14 | |
11939091991 | value comparison works because each value is a primitive type, while trying to compare object references only work if the object reference is compared to itself | What is the difference between comparing values and objects? | 15 | |
11938775146 | Both arrays would reference the same actual array. | Given an array "double[] values = new double[6]", would "double[] prices = values" create a new array or point to the same reference as the other? | 16 | |
11938816770 | Use Arrays.copyOf(array, n)- continuing with the example one could do double[] prices = Arrays.copyOf(values, values.length); You could also use this to expand an existing array with new slots by creating a copy with n > values.length | How would you make a copy of an array that does not result in a reference to the same array? | 17 | |
11939680837 | Relational Operators | What compares values? | 18 | |
11939702625 | Boolean variable | Where can you store the outcome of a condition? | 19 | |
11940446217 | for (dataType elementVariable : array){ statement; } | Format of enhanced for loop | 20 | |
11940459380 | An array of arrays. Represents a table of variables with rows and columns. | Two-dimensional Arrays3 | 21 | |
11940982143 | Step through the instructions and track the values of each variable. | How does one execute a hand trace? | 22 | |
11941005925 | 'count' only exists in the while loop, it can not be accessed outside of it. For each iteration of the while loop, 'count' is created again | Where does the variable 'count' exist? while (count != 5){ sumOtherRandomCode(); count++ } | 23 | |
11941061961 | 'i' is not declared. It should be 'int i'. Because the value of i is never less than -20, it will never run. | What is wrong with the following code? for (i = 10; i < -20; i ++){ sumRandomCodeHere(); } | 24 | |
11941087009 | Input validation, because it runs at least once. Use a sentinel variable to denote the end of a data set. | What is a do Loop best for? | 25 | |
11941144514 | Use a nested loop. for (int i = 0; i < array.length; i ++) { for (int j = 0; j < array[0].length; j ++) { code; } } | How do you traverse through a 2D array? | 26 | |
11941334931 | C is the correct answer. A will throw a syntax error (= always goes on RIGHT), B is a boolean, D is an assignment operator. | Which of the following operators is a relational operator? A) =< B) ! C) <= D) = | 27 | |
11941362788 | Yes, but it only checks whether it refers to the same object. Note that == is only for literals, or numbers. Use str.equals(str2) for strings. | Can you use == for Strings? | 28 | |
11941460147 | Literals in Java are a sequence of characters (digits, letters, and other characters) that represent constant values to be stored in variables. These are NOT java objects. | What is a literal? | 29 | |
11941479192 | Primitive types are the most basic data types available within the Java language. There are 8: boolean, byte, char, short, int, long, float and double. | What is a primitive value? | 30 | |
11941498522 | No, because a String (notice the capital S) is a java object and not a data type. | Are strings a primitive value? | 31 | |
11941464973 | to test whether two Strings are equal to each other, use the equals method (do not use == operator) or the compareTo method to compare their lexiographic order | Comparing Strings | 32 | |
11941453110 | The common programming structure that implements "conditional statements". | What is an if statement? | 33 | |
11942134968 | A set of related classes | Package | 34 | |
11942168942 | a method that changes the state of an object | mutator method | 35 | |
11942176923 | fetches private data stored within an object | accessor method | 36 | |
11942232608 | A class that gives access to the use of multi-character words, phrases, etc.; does not require an import statement | String class | 37 | |
11942542788 | Runs ("do") a specified subprocess while a specified condition is true. | Do while | 38 | |
11942550047 | for(int i=1; i<10; i++){ } | What is proper format for a for loop? | 39 | |
11942866231 | array.remove(position); | How do you remove an element in an array list from a specific position in the array? | 40 | |
11942931114 | ArrayList | How do you set up an arraylist for a list of Strings? | 41 | |
11943012279 | Checks and runs if the condition is met and the program did not go through the previous if/else if statement(s) | else if | 42 | |
11943015364 | Runs when the program went through none of the if/else if statement(s) above; always placed at the very end | else | 43 | |
11946303001 | They are a quick way to check if one variable is equal to many things without having to use a lot of if statements | What are switch case statements useful for? | 44 | |
11946830638 | Executes certain code for a set number of times (based on a condition) | What does a for loop do? | 45 | |
11946843158 | Executed certain code while a statement is true | What does a while loop do? | 46 | |
11948825899 | The name for a class should be a noun and capitalized. It cannot contain special characters or start with a number. | What are the guidelines for naming a class? | 47 | |
11948925221 | No. If it is only a single operation, it can be converted to a method. | Is turning a single operation into a class advisable? | 48 | |
11949253490 | Value < 0 = str1 comes before str2 in lexicographic order Value = 0 = str1 and str2 are the same string Value > 0 = str2 comes before str1 in lexicographic order | What are the possible return values of the str1.compareTo(str2) method, and what do they represent? | 49 | |
11949307628 | Nothing will be stored; the null value represents the lack of an object, not an empty string | If a String variable str1 is set equal to the "null" value, what String literal will be stored in the variable? | 50 | |
11951025832 | doubles have a decimal point. | How does a double differ from an int? | 51 | |
11951037304 | It can store more data | Why would one use a long instead of an int? | 52 | |
11951465263 | Int, Char, Float, Double, Guassian, boolean | Name one primitive type | 53 | |
11951473619 | A class containing a sequence of characters | What is a string | 54 | |
11951496981 | Double is a class with methods for doubles while double is a primitive type | What's the difference Double and double? | 55 | |
11951505818 | Short is a class with methods for shorts while short is a primitive type | What's the difference Short and short? | 56 | |
11951505819 | Byte is a class with methods for bytes while byte is a primitive type | What's the difference Byte and byte? | 57 | |
11951505820 | Integer is a class with methods for ints while int is a primitive type | What's the difference Integer and int? | 58 | |
11951505821 | Long is a class with methods for longs while long is a primitive type | What's the difference Long and long? | 59 | |
11951508694 | Character is a class with methods for chars while char is a primitive type | What's the difference Character and char? | 60 | |
11951588620 | Int[][] name; | How would you initialize a 2d integer array? | 61 | |
11951611194 | [Y][X], also as [row][column] | Are arrays indexed [X][Y] or [Y][X] | 62 | |
11951616011 | Java.util.Scanner; | What class needs to be imported to use a scanner? | 63 | |
11951713427 | George.get(5) | How do you get value 5 from an ArrayList named George? | 64 | |
11951733490 | Random r = new Random(); double q = r.nextDouble(); | How do you generate a random double? | 65 | |
11951757612 | No | If you remove a value from an array, do the other values shift down? | 66 | |
11951757613 | Yes, automatically. | If you remove a value from an ArrayList, do the other values shift down? | 67 | |
11951760298 | An arraylist. | What is an expandable list called. | 68 | |
11951581427 | Boolean is a class with methods for the primitive type of booleans. | What's the difference between boolean and Boolean? | 69 | |
11951733269 | Top left | Does array[0][0] point to the array's bottom left or top left? | 70 | |
11951782650 | You receive an error out of bounds exception | What happens when you call a value outside of an arrays bound. | 71 | |
11951773770 | Yes | Should the names of classes be capitalized? | 72 | |
11951778090 | No | Should the names of packages be capitalized? | 73 | |
11951800668 | BufferedImage | What class are images stored in? | 74 | |
11951801667 | i++ | What code increments a for loop with int i? | 75 | |
11951781627 | for(int i = 0; i< array.length; i++){ for(int j = 0; j< array.length; j++){ number = array[i][j]; } } | How do you iterate through a two dimensional array? | 76 | |
11951874884 | A type with two possible values: true and false. | Boolean type | 77 | |
11951881650 | A loop that is contained in another loop | Nested loop | 78 |
AP CSA Unit 2 Flashcards
Primary tabs
Need Help?
We hope your visit has been a productive one. If you're having any problems, or would like to give some feedback, we'd love to hear from you.
For general help, questions, and suggestions, try our dedicated support forums.
If you need to contact the Course-Notes.Org web experience team, please use our contact form.
Need Notes?
While we strive to provide the most comprehensive notes for as many high school textbooks as possible, there are certainly going to be some that we miss. Drop us a note and let us know which textbooks you need. Be sure to include which edition of the textbook you are using! If we see enough demand, we'll do whatever we can to get those notes up on the site for you!