








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive review of essential java programming concepts for ap computer science a students. Topics covered include the structure of a java program, identifiers, primitive types, variables, methods, exceptions, and more. It also includes coding examples and explanations of key terms and concepts. This document serves as a valuable resource for students preparing for the ap exam.
Typology: Exams
1 / 14
This page cannot be seen from the preview
Don't miss anything!
A Java program must have at least ___ class(es). - Answer>> 1 The java files that comprise your program are called... - Answer>> source files A __________ converts source code into a machine readable form. - Answer>> compiler All Java methods must be contained in a(n)... - Answer>> class All program statements must be placed inside a(n)...
A(n) ____ is a name for a variable, parameter, constant, user-defined method, or user-defined class
What are the three escape sequences necessary to know for the AP exam? - Answer>> \n, ", \ if, if-else, nested if, and extended if statements are all known as ______-______ control structures. - Answer>> decision-making Name the two control structures that allow the computer to perform iterative tasks. - Answer>> for loop and while loop The following is known as what kind of loop? for (SomeType element : collection) { statements; } - Answer>> for-each A(n) __________ is an error condition that occurs during the execution of a Java program. - Answer>> exception If you divide an integer by zero, what kind of error is thrown? - Answer>> ArithmeticException
If you use a negative array index, what kind of error is thrown? - Answer>> ArrayIndexOutOfBoundsException A(n) __________ exception is thrown to indicate that a parameter does not satisfy a method's precondition - Answer>> IllegalArgumentException The ________ of the class provide behaviors exhibited by an object and the operations that manipulate the object - Answer>> methods In the AP Java subset, all classes are... - Answer>> public Give the formula for a method header. - Answer>> access specifier, return type, method name, parameter list All methods defined in the main program must be... - Answer>> static ________ methods are two or more methods in the same class that have the same name but different parameter lists. - Answer>> overloaded A method's signature consists of... - Answer>> the method name and parameter types
When will the equals() method return true? - Answer>> If the objects being compared reference the same memory slot The default implementation of equals() is equivalent to what operator? - Answer>> == What does a string literal consist of? - Answer>> zero or more characters, escape sequences, surrounded by double quotes String objects are immutable. What does this mean?
What does the concatenation operator do with a String and a primitive type? - Answer>> the primitive type is converted to a String, and the two are combined into one String How does the compareTo method compare Strings?
All of the functions and constants in the Math class are... - Answer>> static How do you invoke methods in the Math class? - Answer>> Math, followed by the dot operator What is the range of the result when Math.random() is called? - Answer>> (inclusive) 0.0 to less than 1. True or false: Math.random() can return a random real number from 0.0 up to (but NOT including) 1.0. - Answer>> True Provide code to find a random real value in the range 0.0 to < 6.0. - Answer>> 6 * Math.random(); Provide code to find a random real value in the range 2.0 to <3.0. - Answer>> Math.random() + 2 Provide code to find a random real value in the range 4.0,6.0. - Answer>> 3 * Math.random() + 4 What is the formula to produce a random real value in the range lowValue<=x<highValue? - Answer>> (highValue - lowValue) * Math.random() + lowValue;
Provide code to find a random integer in the range [0,99]. - Answer>> (int) (Math.random() * 100) Provide code to find a random integer in the range [1,100]. - Answer>> (int) (Math.random() * 100) + 1 When does a compile-time error occur? - Answer>> during compilation of the program What happens during a compile-time error? - Answer>> the compiler cannot translate the program into bytecode and prints an error What causes a syntax error? - Answer>> violating the rules of the programming language When does a run-time error occur? - Answer>> during the execution of the program When a run-time error occurs, what exactly throws the exception? - Answer>> the Java run-time environment What does it mean when an exception is thrown? - Answer>> execution stops and an error message is printed
When an array with doubles or ints is declared, what are the values automatically initialized to? - Answer>> 0 When an array with boolean values is declared, what are the values automatically initialize to? - Answer>> false When an array with object references is declared, what are the elements automatically initialized to? - Answer>> null Small arrays whose values are known can be declared with a(n)... - Answer>> initializer list When getting the length of an array, do you use parentheses? Why or why not? - Answer>> no, because it's not a method What should you use to traverse elements in an array? - Answer>> a for loop When passing an array as a parameter, can you modify it? Why or why not? - Answer>> Yes, because you're passing its object reference and not a copy
What is a recursive method? - Answer>> A method that calls itself What happens when a method actually terminates in a recursive loop? - Answer>> The program returns to the most recent call What are the two parts of a recursive method? - Answer>> a base case and a non-base case What is a base case? - Answer>> a termination condition that causes the method to end What is a nonbase case? - Answer>> actions that move the algorithm towards termination True or false: A recursive algorithm cannot have more than one base case. - Answer>> false Define tail recursion. - Answer>> When a method has no pending statements after its recursive call What is infinite recursion? - Answer>> when a recursive method has no base case What error will be thrown if infinite recursion occurs?