Ch. 5 Flashcards

1
Q

<p>

| What is an object reference variable?</p>

A

<p>

| A variable that points to some location in the computer&#39;s memory</p>

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

<p>

| What happens if we make a reference variable with no object in it?</p>

A

<p>

| It becomes a null object</p>

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

<p>

| How do you determine if an object is null?</p>

A

<p>
You need to make an if statement in the object with a println. Like, if it is null, then something will be printed</p>

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

<p>

| What type of variable is an instance variable?</p>

A

<p>

| Null</p>

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

<p>

| What happens if you follow a null reference?</p>

A

<p>

| You get a NullPointerException because the object is not initialized</p>

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

<p>

| What does a NullPointerException allow?</p>

A

<p>

| A method to refer to its own object, like refering to myself as I</p>

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

<p>

| What are multiple references to the same object called?</p>

A

<p>

| Ailiases</p>

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

<p>

| What happens when an assignment operation is used with object references?</p>

A

<p>

| The memory location is copied</p>

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

<p>

| What happens if an object&#39;s state is changed through a reference?</p>

A

<p>

| The sate of the object for all references is changed</p>

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

<p>

| Why does changing one reference change all references?</p>

A

<p>

| They all point to the same location in memory</p>

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

<p>

| What happens if you use == to test object references for equality?</p>

A

<p>

| It tests to see if the aliases are the same. You need to do nam1.equals(name2)</p>

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

<p>

| What happens to parameters in Java?</p>

A

<p>

| They are passed by value</p>

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

<p>

| What happens when we pass an object into a method?</p>

A

<p>

| It becomes an alias of the formal parameter</p>

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

<p>

| What is a static method?</p>

A

<p>

| One that does not require an object. Just do class.method()</p>

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

<p>

| What type of methods are the entire math class?</p>

A

<p>

| Static</p>

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

<p>

| What is a static variable like?</p>

A
<p style="text-align: center;">
	They are not tied to a particular object, they are a class variable</p>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

<p>

| What happens when static variables are loaded with the class?</p>

A

<p>

| Space is created for them because they will be used thorughout the class</p>

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

<p>

| What are static variables most commonly used for?</p>

A

<p>

| Constraints</p>

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

<p>

| What can be interchanged in static methods?</p>

A

<p>

| The modifiers, but usually the visibility ones are put furst anyway</p>

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

<p>

| How is the main method static?</p>

A

<p>

| It is invoked without creating an object</p>

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

<p>

| What kinds of variables can be used with static methods?</p>

A

<p>

| Static variables or local variables. NO INSTANCE VARIABLES</p>

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

<p>

| What is the chain of exceptions?</p>

A

<p>

| A program throws exceptions which are caught or handled by other parts of the program</p>

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

<p>

| What is an exception?</p>

A

<p>

| A part of a program that describes an unusual or erroneous sistuation</p>

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

<p>

| How is a program divided?</p>

A

<p>

| The normal execution flow and the exception execution flow</p>

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

<p>

| What is an error in java?</p>

A

<p>

| An object that may sometimes represent an unrecoverable situtation and should not be caught</p>

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

<p>

| What is &quot;Not Responding&quot;?</p>

A

<p>

| An error that is trying to be caught but it&#39;s not really working out</p>

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

<p>

| What must a programmer always ensure?</p>

A

<p>

| An object reference variable refers to a valid object</p>

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

<p>

| What is a this reference?</p>

A

<p>

| When an object refers to itself</p>

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

<p>

| What does java have for when something goes wrong?</p>

A

<p>

| A built in set of exceptions</p>

30
Q

<p>

| What can we make to go off whenever we want?</p>

A

<p>

| Our own exceptions</p>

31
Q

<p>

| How are exceptions handled?</p>

A

<p>

| Ignoring it, handling it where it occurs, and handling it somewhere else in the program</p>

32
Q

What happens when an exception is ignored?

A

The program crashes and returns an appropriate message

33
Q

What happens when an exception is handled where it occurs?

A

The user is promted to fix whatever is wrong. This is the best way to do things

34
Q

What is call stack trace?

A

Laying out where the exception occured to show where the program was when the crash occured for troubleshooting and shows the method call trail right before the crash

35
Q

Where are exception throw statements found?

A

Nested in if satements to determine if an exception should be thrown

36
Q

How do you throw an exception?

A

throw new NameException()

37
Q

What is an interface?

A

A collection of abstract methods and constants, where a header is provided but not a body

38
Q

What are all methods in an interface by default?

A

Abstract

39
Q

What is an interface like?

A

A to do list for a class, like saying we need these methods but we don’t actually make them

40
Q

What can’t you do with interfaces?

A

Instantiate them because they’re not objects

41
Q

What type of visibility do interface methods have by default?

A

Public

42
Q

What is required for interfaces?

A

The methods stated in it need to be defined elsewhere

43
Q

What is implementing an interface?

A

Actually doing the math and spelling things out

44
Q

What can an interface contain?

A

Constants

45
Q

What may an interface’s class contain?

A

Multiple interfaces

46
Q

how do you set up an interface?

A

class ClassName implements interface1, interface2

47
Q

What must a programmer decide?

A

How to define an interface’s abstrac method?

48
Q

What comes with Java?

A

A prewritten interface with a list of abstract methods

49
Q

What is implemented with the list interface?

A

Classes that contain an ordered collection of elements

50
Q

What is defined with the comparable interface?

A

the compareTo method which is used to compare stuff

51
Q

What does an iterator do?

A

Allow a user to move easily through a collection of objects, doing something with each object

52
Q

What is usually used with Compareable?

A

A string compared via lexiographic ordering

53
Q

What is the comparable test?

A

if obj1obj2, 1

54
Q

How fast do iterators work?

A

1 thing at a time

55
Q

What does the Next method do?

A

Return the next object in the iteration

56
Q

What does the hasNext method do?

A

Return a boolean that is true when there is nothing left to process

57
Q

What do objects usually represent?

A

Nouns

58
Q

What do classes represent?

A

Object groups with similar behaviors

59
Q

What is necessary in a class>

A

General and specific classes… ie not too much in a class

60
Q

what is state?

A

Something’s representation

61
Q

What is behavior?

A

What it does

62
Q

What is a nested class?

A

A class within a class

63
Q

What is the enclosed and outer class?

A

Enclosed is the nested class, outer is the nested class host

64
Q

What is a nested class like?

A

A huge class that accesses all of the variable in the enclosing class

65
Q

How is a nested class protected?

A

The outer class can prevent data leaking

66
Q

What is separated with an enclosed and outer class?

A

The bytecode files

67
Q

What types of objects compose a gui?

A

components, events, and listeners

68
Q

What is a gui component?

A

the pieces that put together a gui, like buttons and menus

69
Q

What is a gui event>

A

What we do with the computer, like typing and moving arond the mouse

70
Q

What does the gui listener do?

A

What actually does something, like running code