Unit 2 AP Comp Sci A

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 27

28 Terms

1

What is the class and object of:

String tree = new String(“oak”);

Class: String

Object: tree

New cards
2

Null in Java

Represents an object or class data type that has not been created.

New cards
3

Two basic types of data types in Java

Primitive types and class (reference) types.

New cards
4

Primitive type

Holds only one piece of data at a time (e.g. int,double,boolean)

New cards
5

Class (reference) type

Can hold more than one piece of data at a time and is a blueprint that defines the properties and methods that objects created from it will have.

New cards
6

How primitive data types are stored in memory

As the actual value (e.g., int number 13, stores 13)

New cards
7

How class data types are stored in memory

As a memory address pointing to where the actual value is stored (e.g., String a = "Howdy";).

New cards
8

No reference set for a String

Holds the value null

New cards
9

Strings are immutable

They cannot be changed once created. If you modify a string, a new one is created instead of altering the original.

New cards
10

What would be the output of this code?

String alpha = "Toy Story"; 

String beta = alpha; 

alpha = alpha + " 2"; 

System.out.println(alpha); 

System.out.println(beta);

Toy Story 2

Toy Story

New cards
11

Three ways to create Strings in Java

String alpha = "Wonder Woman";`  

String beta;

beta = "Superman";

String gamma = new String("Spiderman");

New cards
12

+ operator in Java

Concatenates strings and adds integers.

New cards
13

Concatenation with strings

"Glues" two strings together (e.g.

New cards
14

+= operator with strings

combines the two strings into one

New cards
15

Controlling order of operations with strings and integers

By using parentheses

New cards
16

Escape sequences in Java

\" - double quote  

\n - new line  

\t - horizontal tab  

\\ - backslash  

\' - single quote 

New cards
17

Characters stored in a string

Each character is stored with an index starting at 0.

New cards
18

.length() method

Returns the number of characters in the string.

New cards
19

String s = “charizard”;

String t = “charizard”;

s.equals(t)

Tests if two strings are equal (returns true or false).

New cards
20

.substring(start,stop)

gets a part of a string from the start index to the stop index (not including the stop)

New cards
21

.toUpperCase() and .toLowerCase() methods

Convert all letters to uppercase or lowercase

New cards
22

.compareTo(other)

Compares two strings alphabetically.

New cards
23

.indexOf(str)

Searches for a character or string and returns its index position.

New cards
24

Class in Java

"Recipe" for creating objects.

New cards
25

Object in Java

Specific instance of a class.

New cards
26

Example of creating a String object

String tree = new String("oak")

New cards
27

Keyword new in Java

Allocates memory for the new object.

New cards
28

Assigning one object to another

Both variables now point to the same memory location.

New cards

Explore top notes

note Note
studied byStudied by 8 people
340 days ago
5.0(1)
note Note
studied byStudied by 64 people
145 days ago
5.0(1)
note Note
studied byStudied by 230 people
849 days ago
5.0(1)
note Note
studied byStudied by 6 people
711 days ago
5.0(1)
note Note
studied byStudied by 5 people
98 days ago
5.0(1)
note Note
studied byStudied by 92 people
91 days ago
5.0(3)
note Note
studied byStudied by 18 people
830 days ago
5.0(1)
note Note
studied byStudied by 8907 people
656 days ago
4.8(41)

Explore top flashcards

flashcards Flashcard (52)
studied byStudied by 3 people
616 days ago
5.0(1)
flashcards Flashcard (49)
studied byStudied by 3 people
737 days ago
5.0(1)
flashcards Flashcard (47)
studied byStudied by 106 people
483 days ago
5.0(1)
flashcards Flashcard (160)
studied byStudied by 1 person
614 days ago
5.0(1)
flashcards Flashcard (75)
studied byStudied by 14 people
765 days ago
5.0(1)
flashcards Flashcard (25)
studied byStudied by 3 people
435 days ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 14 people
588 days ago
5.0(1)
robot