AP Computer Science Fall Review

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/112

flashcard set

Earn XP

Description and Tags

Fall Review of AP Computer Science

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

113 Terms

1
New cards

Class

A blueprint for creating objects that defines a set of attributes and methods.

2
New cards

Object

An instance of a class that contains actual values.

3
New cards

Constructor

A special method used to initialize objects in a class.

4
New cards

Null Reference

Indicates that a reference variable does not point to any object.

5
New cards

Formal Parameters

The variables defined by a method or constructor that receive values.

6
New cards

Actual Parameters

The actual values passed into the constructor or method when invoked.

7
New cards

Overloaded Constructor

Constructors with the same name but different parameter lists.

8
New cards

Void Method

A method that does not return any value.

9
New cards

Immutable String

A String whose value cannot be changed once created.

10
New cards

Autoboxing

Automatic conversion from a primitive type to its corresponding wrapper class.

11
New cards

Integer.MIN_VALUE

This represents the smallest value an integer can have.

12
New cards

Math.pow

A method that raises a base to the power of an exponent.

13
New cards

Math.sqrt

A method that returns the square root of a number.

14
New cards

Exception

An error condition that alters the normal flow of program execution.

15
New cards

String Concatenation

The process of joining two or more strings together.

16
New cards

Random Integer Generation

A method to produce a random integer value within a specified range.

17
New cards

private

A keyword used to restrict access to a variable, allowing it to be accessed only within the declaring class.

18
New cards

public instance variables

Should generally be marked private for encapsulation (since they are not public).

19
New cards

this keyword

Refers to the current object, allowing access to its instance variables or methods.

20
New cards

accessor method

A type of method typically used to provide access to private instance variables.

21
New cards

static keyword

Used to define a class-level shared variable.

22
New cards

default access modifier

It is accessible within the same package (Private-Package).

23
New cards

Comments(Javadoc)

Documenting API functionality typically uses this type of comment (/** */).

24
New cards

constructor naming

constructors must have the same name as the class.

25
New cards

default no-argument constructor

Provided by Java if no constructor is specified for a class.

26
New cards

single-line comment in Java

An example would be: // This is a single-line comment.

27
New cards

mutable objects

Should be copied before being assigned to instance variables to avoid unintended modifications.

28
New cards

static variable purpose

Associates the variable with the class rather than any specific instance.

29
New cards

accessor vs mutator methods

Accessor methods retrieve values, while mutator methods modify values.

30
New cards

method header for getName

public String getName()

31
New cards

toString method behavior

If not overridden, it returns the object's class name and hash code.

32
New cards

static method access

a static method cannot access instance variables of the class.

33
New cards

local vs instance variable conflict

The local variable is used, shadowing the instance variable.

34
New cards

constructor header for Student

public Student(String name, int age)

35
New cards

data encapsulation

Restricting access to an object's internal state and exposing controlled access through methods.

36
New cards

this keyword conflict resolution

It specifies that the instance variable should be used (this.variableName).

37
New cards

accessor method for private id

public int getId() { return id; }

38
New cards

ethical considerations in class design

Ensuring data security and privacy by implementing proper access controls and avoiding data leaks.

39
New cards

Java class Book example

public class Book { private String title; private String author; public Book(String title, String author) { this.title = title; this.author = author; } }

40
New cards

output of Counter class code

Count: 1

41
New cards

error in getPrice method

Should return an int; to fix: public int getPrice() { return price; }

42
New cards

toString method for Book class

public String toString() { return "Title: " + title + ", Author: " + author; }

43
New cards

output of StaticExample class

2, indicating how many instances of the class were created.

44
New cards

While Loop

A control flow statement that allows code to be executed repeatedly based on a given boolean condition.

45
New cards

For Loop

A control flow statement that allows code to be executed a specific number of times, with a defined initialization, condition, and increment.

46
New cards

Increment Section

The part of a for loop that specifies how the loop control variable should change after each iteration.

47
New cards

Boolean Condition

An expression evaluated to true or false to control the flow of loops.

48
New cards

Off by One Error

A common programming error where a loop iterates one too many or one too few times, often related to the starting or ending conditions.

49
New cards

Nested Loop

A loop inside another loop, where the inner loop executes completely for each iteration of the outer loop.

50
New cards

Return Statement in a Loop

A statement used to exit a function, which also results in exiting any loop that encloses it.

51
New cards

String Traversal Algorithm

An algorithm that goes through each character of a string to perform actions like counting vowels.

52
New cards

Maximum Value in Array

The largest number found in a given array of integers.

53
New cards

Reverse a String

An algorithm that creates a new string consisting of characters in the opposite order of their original arrangement.

54
New cards

Relational Operator

An operator that compares two values and returns a boolean result.

55
New cards

Boolean Expression

An expression that evaluates to either true or false.

56
New cards

Short-Circuited Evaluation

A method of evaluating logical expressions that stops as soon as the result is determined.

57
New cards

&& Operator

The logical AND operator that returns true only if both operands are true.

58
New cards

|| Operator

The logical OR operator that returns true if at least one of the operands is true.

59
New cards

Null Reference

A reference that does not point to any object.

60
New cards

De Morgan’s Laws

A pair of transformation rules that relate conjunctions and disjunctions of propositions.

61
New cards

If-Else Statement

A control structure that executes different blocks of code based on a boolean condition.

62
New cards

Boolean Negation

The operation of inverting the truth value of a boolean expression.

63
New cards

Truth Table

A table that shows all possible truth values for a logical expression.

64
New cards

Default value of uninitialized int in Java

value of uninitialized int = 0

65
New cards

Primitive type for true/false values

Boolean

66
New cards

Declaration for a String variable named 'name'

String name;

67
New cards

Primitive type for decimal numbers

double

68
New cards

Result of 10 / 4 in integer division

2

69
New cards

Declaration for a boolean variable named 'isActive'

boolean isActive;

70
New cards

What happens when an int is divided by a double?

It auto casts to double.

71
New cards

Default value of a boolean in Java

false or 0

72
New cards

Primitive types on the AP Test

int, double, boolean

73
New cards

Result of 3.0 / 2 in Java

1.5

74
New cards

Result of true || false

the result will be True (or/and prob)

75
New cards

Result of true && false

The result will be False (and/or prob)

76
New cards

Evaluation of !(x == 5) when x = 5

This expression evaluates to false because the equality check "x == 5" is true, and the logical NOT operator negates that result.

77
New cards

Boolean expression for x not between 10 and 20 inclusive

!(x >= 10 && x <= 20)

78
New cards

Result of !(a > 5 || b < 3) when a = 6 and b = 2

6 is less than 5 and 2 is less than 3 the negation function will make it false

79
New cards

Simplification of !(x && y) using De Morgan's Law

!x || !y

80
New cards

Simplification of !(a || b) using De Morgan's Law

!a && !b

81
New cards

Simplification of !(x > 5 && y < 10) using De Morgan's Law

!x || y >= 10

82
New cards

Output of System.out.println(a / 2 * 2) when a = 7

6

83
New cards

Issue with 'double value = 3.7; int num = value;'

Cannot assign a double to an int without explicit casting.

84
New cards

Code to declare int variable 8, cast to double and print

int num = 8; double result = (double) num; System.out.println(result);

85
New cards

Boolean expression for x divisible by 3 but not by 5

x % 3 == 0 && x % 5 != 0

86
New cards

Output when x = 5 and x > 3 && x < 10

this will be True since 5 is bigger than 3 and smaller than 10

87
New cards

Result of ! (10 > 5 || 2 < 3)

even though 10 is bigger that 5 and 2 is less than 3 negation will make it False

88
New cards

Result when x = 8, y = 6 for x == 8 || y != 5 && y == 6

The result is true because x equals 8.

89
New cards

Default value of uninitialized int variable in Java

The default value of an uninitialized int variable in Java is 0.

90
New cards

Primitive type for true/false values

Boolean

91
New cards

Valid declaration for a String variable

String name;

92
New cards

Primitive type for storing decimal numbers

double

93
New cards

Result of 10 / 4 in integer division

2

94
New cards

Declaration of a boolean variable

boolean simesterDone;

95
New cards

Result when dividing an int by a double

It auto casts to double.

96
New cards

Default value of a boolean in Java

false (Boolean value)

97
New cards

Primitive types on the AP Test

int, double, boolean

98
New cards

Result of 3.0 / 2 in Java

1.5

99
New cards

Result of true || false

will produce true (|| statement)

100
New cards

Result of true && false

will produce False (&& statement)