1/34
Flashcards for AP Computer Science A exam review focusing on primitive types, objects, boolean expressions, iterations, classes, arrays, ArrayLists,
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the difference between System.out.print and System.out.println in Java?
println moves the cursor to a new line after displaying the given data, while print does not.
How are single-line and multi-line comments denoted in Java?
Single-line comments are denoted by //, and multi-line comments are demarcated by /* and */.
What are the three primitive types used in AP Computer Science A?
int, double, and boolean
What are literals in Java?
Representations in code of exact values.
What is the result of dividing two int values in Java?
The result is an int, truncating any non-integer part.
What happens when an arithmetic operation involves at least one double value?
The result will be a double.
What is a variable in Java?
A name that is associated with a piece of computer memory that stores a value.
What is a variable declaration statement?
Consists of a type followed by a name (e.g., int age;).
What is the purpose of the 'final' keyword in variable declarations?
It indicates that the variable's value will never change after it is initially assigned.
What is a compound operator in Java?
An operator that combines an arithmetic operation and assignment (e.g., +=, -=, *=, /=, %=).
What are increment and decrement operators in Java?
Operators that add one (++) or subtract one (--) from a variable's value.
What is casting in Java?
Using operators (int) and (double) to create temporary values converted to another type.
What happens when casting a double to an int?
It results in truncation of the decimal portion.
What is a class in Java?
A blueprint, or template, for the objects of a certain type that specifies the attributes and methods an object will have.
How is an object created from a class?
By calling the class constructor along with the new keyword.
What is the signature of a constructor?
The name of the constructor along with the list of types of parameters that it expects.
What does it mean for a constructor to be overloaded?
A class may define multiple constructors as long as their signatures differ.
What is a reference variable?
A variable that refers to an object, storing a reference to the object's location in memory, rather than the object itself.
What is the special value 'null' used for?
Reference variables that do not contain a reference to any actual object.
How is interaction with objects primarily done?
By calling their methods.
What is the signature of a method?
Consists of its name along with a (possibly empty) list of the types of parameters it defines.
What are void methods?
Methods that do not return a value and can only be called as standalone statements.
What happens if a method is called on a 'null' value?
A NullPointerException is thrown.
How can a String object be created?
By simply using literal values, without explicitly calling the constructor with the 'new' keyword.
What is concatenation in the context of strings?
Combining strings using the '+' operator.
What are escape sequences in Java?
Series of characters beginning with a backslash that has special meaning.
What is the index of characters in a string?
The position of a character, starting at 0.
Which of the following methods are included in the AP Computer Science A exam (String(String str))?
constructs a new string that is identical to str
Which of the following methods are included in the AP Computer Science A exam (int length())?
returns the number of characters in the string
How is polymorphism implemented in Java?
It is implemented through method overriding
Which of the following methods are included in the AP Computer Science A exam (String compareTo(String other))?
returns a negative value if the string comes before other, a positive value if the string comes after other, and 0 if the two are equal
What does it mean for strings to be immutable?
They have no mutator methods; methods like substring return a new string and do not modify the original.
What are autoboxing and unboxing?
Features of the Java compiler that automatically convert between wrapper classes and the corresponding primitive types.
Which of the following Boolean expressions are equivalent to the expression (!(A && B))?
(!A || !B)
If an object has an equals method, and you want to check if it is not equal to another object, what idiom you can use?
(!obj1.equals(obj2))