Ch. 5 Flashcards Preview

Comp Sci > Ch. 5 > Flashcards

Flashcards in Ch. 5 Deck (70)
Loading flashcards...
1


What is an object reference variable?



A variable that points to some location in the computer's memory


2


What happens if we make a reference variable with no object in it?



It becomes a null object


3


How do you determine if an object is null?



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


4


What type of variable is an instance variable?



Null


5


What happens if you follow a null reference?



You get a NullPointerException because the object is not initialized


6


What does a NullPointerException allow?



A method to refer to its own object, like refering to myself as I


7


What are multiple references to the same object called?



Ailiases


8


What happens when an assignment operation is used with object references?



The memory location is copied


9


What happens if an object's state is changed through a reference?



The sate of the object for all references is changed


10


Why does changing one reference change all references?



They all point to the same location in memory


11


What happens if you use == to test object references for equality?



It tests to see if the aliases are the same.  You need to do nam1.equals(name2)


12


What happens to parameters in Java?



They are passed by value


13


What happens when we pass an object into a method?



It becomes an alias of the formal parameter


14


What is a static method?



One that does not require an object.  Just do class.method()


15


What type of methods are the entire math class?



Static


16


What is a static variable like?



They are not tied to a particular object, they are a class variable


17


What happens when static variables are loaded with the class?



Space is created for them because they will be used thorughout the class


18


What are static variables most commonly used for?



Constraints


19


What can be interchanged in static methods?



The modifiers, but usually the visibility ones are put furst anyway


20


How is the main method static?



It is invoked without creating an object


21


What kinds of variables can be used with static methods?



Static variables or local variables.  NO INSTANCE VARIABLES


22


What is the chain of exceptions?



A program throws exceptions which are caught or handled by other parts of the program


23


What is an exception?



A part of a program that describes an unusual or erroneous sistuation


24


How is a program divided?



The normal execution flow and the exception execution flow


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