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

| What is an error in java?

| An object that may sometimes represent an unrecoverable situtation and should not be caught

26

| What is "Not Responding"?

| An error that is trying to be caught but it's not really working out

27

| What must a programmer always ensure?

| An object reference variable refers to a valid object

28

| What is a this reference?

| When an object refers to itself

29

| What does java have for when something goes wrong?

| A built in set of exceptions

30

| What can we make to go off whenever we want?

| Our own exceptions

31

| How are exceptions handled?

| Ignoring it, handling it where it occurs, and handling it somewhere else in the program

32
What happens when an exception is ignored?
The program crashes and returns an appropriate message
33
What happens when an exception is handled where it occurs?
The user is promted to fix whatever is wrong. This is the best way to do things
34
What is call stack trace?
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
Where are exception throw statements found?
Nested in if satements to determine if an exception should be thrown
36
How do you throw an exception?
throw new NameException()
37
What is an interface?
A collection of abstract methods and constants, where a header is provided but not a body
38
What are all methods in an interface by default?
Abstract
39
What is an interface like?
A to do list for a class, like saying we need these methods but we don't actually make them
40
What can't you do with interfaces?
Instantiate them because they're not objects
41
What type of visibility do interface methods have by default?
Public
42
What is required for interfaces?
The methods stated in it need to be defined elsewhere
43
What is implementing an interface?
Actually doing the math and spelling things out
44
What can an interface contain?
Constants
45
What may an interface's class contain?
Multiple interfaces
46
how do you set up an interface?
class ClassName implements interface1, interface2
47
What must a programmer decide?
How to define an interface's abstrac method?
48
What comes with Java?
A prewritten interface with a list of abstract methods
49
What is implemented with the list interface?
Classes that contain an ordered collection of elements
50
What is defined with the comparable interface?
the compareTo method which is used to compare stuff
51
What does an iterator do?
Allow a user to move easily through a collection of objects, doing something with each object
52
What is usually used with Compareable?
A string compared via lexiographic ordering
53
What is the comparable test?
if obj1obj2, 1
54
How fast do iterators work?
1 thing at a time
55
What does the Next method do?
Return the next object in the iteration
56
What does the hasNext method do?
Return a boolean that is true when there is nothing left to process
57
What do objects usually represent?
Nouns
58
What do classes represent?
Object groups with similar behaviors
59
What is necessary in a class>
General and specific classes... ie not too much in a class
60
what is state?
Something's representation
61
What is behavior?
What it does
62
What is a nested class?
A class within a class
63
What is the enclosed and outer class?
Enclosed is the nested class, outer is the nested class host
64
What is a nested class like?
A huge class that accesses all of the variable in the enclosing class
65
How is a nested class protected?
The outer class can prevent data leaking
66
What is separated with an enclosed and outer class?
The bytecode files
67
What types of objects compose a gui?
components, events, and listeners
68
What is a gui component?
the pieces that put together a gui, like buttons and menus
69
What is a gui event>
What we do with the computer, like typing and moving arond the mouse
70
What does the gui listener do?
What actually does something, like running code