Chapter 2 Flashcards

You may prefer our related Brainscape-certified 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
Q

you have to instantiate object

A

myBook = new Book (“Ender’s Game”, 1985);

26
Q

strings

A

No “new” operator necessary

27
Q

strings are

A

immutable, cannot be changed

28
Q

String length

A

.length()

29
Q

String uppercase

A

.toUpperCase()

30
Q

String lowercase

A

.toLowerCase()

31
Q

Substring

A

name.subtring(start,end);

32
Q

Index

A

.indexOf();

33
Q

instance variables within an object

A

are private

34
Q

to get the hyp variable total we use __, and to set total we use ___

A

getTotal, setTotal

35
Q

int stores

A

32 bits

36
Q

double stores

A

64 bits

37
Q

right and left hand side of an assignment statement can contain

A

the same variable

count = count + 1;

38
Q

new object

A

myBook = new Book (“Ender’s Game”, 1985);

39
Q

New scanner

A

Scanner Scan = new Scanner(System.in);

40
Q

import scanner

A

import java.util.Scanner;

41
Q

intCompareTo

A

indicates whether string comes before or after text, -1 for before vice versa

42
Q

utilities

A

java.util;

43
Q

random

A

(int)(Math.random();

44
Q

store number value

A

var = scan.nextInt();

45
Q

primitive identifiers store,

an object stores

A

actual value, references to objects

46
Q

String class is a part of

A

java.lang;

47
Q

why are static classes called static?

A

they belong to the classes as a whole, not objects

48
Q

How to replace all of one character

A

.replaceAll(thing you want to change, new thing)