Ch. 5 Flashcards
<p>
| What is an object reference variable?</p>
<p>
| A variable that points to some location in the computer's memory</p>
<p>
| What happens if we make a reference variable with no object in it?</p>
<p>
| It becomes a null object</p>
<p>
| How do you determine if an object is null?</p>
<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>
<p>
| What type of variable is an instance variable?</p>
<p>
| Null</p>
<p>
| What happens if you follow a null reference?</p>
<p>
| You get a NullPointerException because the object is not initialized</p>
<p>
| What does a NullPointerException allow?</p>
<p>
| A method to refer to its own object, like refering to myself as I</p>
<p>
| What are multiple references to the same object called?</p>
<p>
| Ailiases</p>
<p>
| What happens when an assignment operation is used with object references?</p>
<p>
| The memory location is copied</p>
<p>
| What happens if an object's state is changed through a reference?</p>
<p>
| The sate of the object for all references is changed</p>
<p>
| Why does changing one reference change all references?</p>
<p>
| They all point to the same location in memory</p>
<p>
| What happens if you use == to test object references for equality?</p>
<p>
| It tests to see if the aliases are the same. You need to do nam1.equals(name2)</p>
<p>
| What happens to parameters in Java?</p>
<p>
| They are passed by value</p>
<p>
| What happens when we pass an object into a method?</p>
<p>
| It becomes an alias of the formal parameter</p>
<p>
| What is a static method?</p>
<p>
| One that does not require an object. Just do class.method()</p>
<p>
| What type of methods are the entire math class?</p>
<p>
| Static</p>
<p>
| What is a static variable like?</p>
<p style="text-align: center;"> They are not tied to a particular object, they are a class variable</p>
<p>
| What happens when static variables are loaded with the class?</p>
<p>
| Space is created for them because they will be used thorughout the class</p>
<p>
| What are static variables most commonly used for?</p>
<p>
| Constraints</p>
<p>
| What can be interchanged in static methods?</p>
<p>
| The modifiers, but usually the visibility ones are put furst anyway</p>
<p>
| How is the main method static?</p>
<p>
| It is invoked without creating an object</p>
<p>
| What kinds of variables can be used with static methods?</p>
<p>
| Static variables or local variables. NO INSTANCE VARIABLES</p>
<p>
| What is the chain of exceptions?</p>
<p>
| A program throws exceptions which are caught or handled by other parts of the program</p>
<p>
| What is an exception?</p>
<p>
| A part of a program that describes an unusual or erroneous sistuation</p>
<p>
| How is a program divided?</p>
<p>
| The normal execution flow and the exception execution flow</p>
<p>
| What is an error in java?</p>
<p>
| An object that may sometimes represent an unrecoverable situtation and should not be caught</p>
<p>
| What is "Not Responding"?</p>
<p>
| An error that is trying to be caught but it's not really working out</p>
<p>
| What must a programmer always ensure?</p>
<p>
| An object reference variable refers to a valid object</p>
<p>
| What is a this reference?</p>
<p>
| When an object refers to itself</p>