APCSA Unit 2

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/42

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:38 PM on 9/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

43 Terms

1
New cards

Object

An instance of a class that contains variables (data) and behaviors (methods).

2
New cards

Object-Oriented Programming (OOP)

A programming style where programs are organized around objects that contain data and behaviors.

3
New cards

Variable

A piece of data attached to an object that helps define the object's state or characteristics.

4
New cards

Behavior (Method)

An action associated with an object; methods are used to make an object do something.

5
New cards

Example of variables in an object

A Fraction object could have a numerator and denominator as variables.

6
New cards

Abstraction

Hiding the details of how something works because the user does not need to know those details to use it.

7
New cards

Example of abstraction

A driver does not need to know exactly how a car's engine works in order to drive the car.

8
New cards

Math Class

A Java class containing static methods that perform common mathematical operations.

9
New cards

Static

A keyword indicating that a method belongs to the class itself and can be called without creating an object of that class.

10
New cards

Math.abs()

Returns the absolute value of a number.

11
New cards

Math.abs(int num)

Returns the absolute value of an integer.

12
New cards

Math.abs(double num)

Returns the absolute value of a double.

13
New cards

Math.pow()

Raises a number to a specified power.

14
New cards

Math.pow(2, 3)

Returns 8.08.0 because 23=82^3 = 8.

15
New cards

Math.random()

Returns a random double greater than or equal to 0.00.0 and less than 1.01.0.

16
New cards

Math.sqrt()

Returns the square root of a number.

17
New cards

Math.sqrt(25)

Returns 5.05.0 because 25=5\sqrt{25} = 5.

18
New cards

Math.pow(double num, double power)

Returns num raised to the given power.

19
New cards

Math class method syntax

Math.methodName(parameters)

20
New cards

Absolute value

The distance of a number from zero; it is always nonnegative.

21
New cards

pow

Short for power; used to raise a number to an exponent.

22
New cards

random

Used to generate a random decimal number from 0.00.0 up to, but not including, 1.01.0.

23
New cards

sqrt

Short for square root; returns the square root of a number.

24
New cards

String object

An object that stores a sequence of characters.

25
New cards

String.indexOf(String str)

Returns the first position (index) where the specified string occurs; returns 1-1 if it is not found.

26
New cards

word.indexOf("E") for word = "COMPUTER"

Returns 66.

27
New cards

word.indexOf("P") for word = "COMPUTER"

Returns 33.

28
New cards

word.indexOf("U") for word = "COMPUTER"

Returns 44.

29
New cards

word.indexOf("Y") when "Y" is not present in word

Returns 1-1.

30
New cards

Index of the first character in a String

00

31
New cards

Indexing of String characters

Starts at 00 and increases by 11 for each character.

32
New cards

String.length()

Returns the length (number of characters) in the String.

33
New cards

String.substring(int from, int to)

Returns a substring starting at the from index and ending before the to index.

34
New cards

String.substring(int from)

Returns a substring starting at the from index and continuing to the end of the String.

35
New cards

boolean equals(String str)

Checks whether two Strings are equal.

36
New cards

int compareTo(String str)

Compares two Strings lexicographically.

37
New cards

Syntax for creating a String object

String variableName = new String("text");

38
New cards

Example of creating a String object

String joMama = new String("is so fat");

39
New cards

Syntax for calling a String method

object.methodName(parameters)

40
New cards

Example of calling substring on an object

String big = joMama.substring(6);

41
New cards

Printing output in Java

System.out.println(...);

42
New cards

substring(1, 3) for "COMPUTER"

"OM"

43
New cards

substring(6) for "COMPUTER"

"ER"