Chapter 2 Flashcards

1
Q

Object

A

Something with which we can interact with the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Class

A

defines objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

System.out is an

A

object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

print is different than println because

A

it does not advance to the next line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Objects are abstract because

A

we don’t have to think about it’s internal details

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Encapsulation

A

Each object handles its own state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

getter

A

used to ask an object the value of a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

setter

A

allows you to ask an object to change the value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

String is an object

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

concatenation

A

when you use the + operator to connect a very long string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

An escape sequence

A

begins with back slash, tell program to treat next letter specially

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

tab

A

\t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

newline

A

\n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

double quote

A

"

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

three steps to make a variable

A

instantiate: declare
initialize: store
use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

assignment

A

stores a value into a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

declaring multiple variable at once is

A

bad form

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

constant

A

final

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

type

A

a category or set of data values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

3 primitive types

A

int
double
boolean

21
Q

widening conversions

A

safe, do not lose information (int to double)

22
Q

narrowing conversions

A

often lost information (double to in)

23
Q

casting

A

we want a floating point result when dividing them, we cast a total

result = (double) total / count;

24
Q

pointer

A

a reference in the address, points to where the object is

25
you have to instantiate object
myBook = new Book ("Ender's Game", 1985);
26
strings
No "new" operator necessary
27
strings are
immutable, cannot be changed
28
String length
.length()
29
String uppercase
.toUpperCase()
30
String lowercase
.toLowerCase()
31
Substring
name.subtring(start,end);
32
Index
.indexOf();
33
instance variables within an object
are private
34
to get the hyp variable total we use __, and to set total we use ___
getTotal, setTotal
35
int stores
32 bits
36
double stores
64 bits
37
right and left hand side of an assignment statement can contain
the same variable count = count + 1;
38
new object
myBook = new Book ("Ender's Game", 1985);
39
New scanner
Scanner Scan = new Scanner(System.in);
40
import scanner
import java.util.Scanner;
41
intCompareTo
indicates whether string comes before or after text, -1 for before vice versa
42
utilities
java.util;
43
random
(int)(Math.random();
44
store number value
var = scan.nextInt();
45
primitive identifiers store, | an object stores
actual value, references to objects
46
String class is a part of
java.lang;
47
why are static classes called static?
they belong to the classes as a whole, not objects
48
How to replace all of one character
.replaceAll(thing you want to change, new thing)