Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
86 Cards in this Set
- Front
- Back
Is java case sensetive? Does java ignore overflow and underflow? |
- Java is case sensetive - java does ignore underflow and over flow ( this means that an integer incremented at maximum value will loop back to minimum value) |
|
What does the declaration of a variable do? |
- arranges for space to be allocated for the variable - ensures only valid operators can be performed on this variable |
|
What is the difference (syntactically) between declaring a variable and initializing a variable? |
Declaration: int cars; Initialization (first assignment): int cars = 5; assignment: cars = 6; In java, a variable can only be declared once. (probably within same method) |
|
compare strings using...? |
obj.equals("string"); NOT == |
|
Formula for comparing doubles |
|
|
what is the output? |
"seven" |
|
3 things happen with evaluation of this double cars = new double[250] |
1. Allocates 250 double precision storage locations 2. variable 'cars' stores the first location 3. initializes each 250 locations to 0.0 |
|
What is the output? |
"CS 1234" alice points to what alicia is pointing to (which is the first location of the string array alicia) |
|
ArrayList jim = new ArrayList(); what is command to add "tom" to array list Jim at first location? |
jim.add(0,"tom"); |
|
1. What is a method signature? 2. How does it relate to overloaded methods? |
1. A method signature is the Method Name, parameter types NOT method type! 2. to overload methods, must have variance in method signature |
|
method parameters are located ... |
public int print(PARAMETER HERE) { } |
|
arguments are located... |
main { Jim j = new Jim(ARGUMENTS HERE) ;
|
|
What is an interface, and why is it used? |
A interface is like an agreement to implement certain method signatures. The methods signatures within the interface do not have bodies. |
|
Can interfaces be instantiated? |
location 8780 |
|
what is an abstract method? |
used in interfaces |
|
What 3 things can an interface NOT have? |
Cannot have 1. method bodies (use abstract method) 2. fields ( other than constants) 3. static methods (because why would an interface need functional methods?) |
|
Fields in interfaces are implicitly declaired..? |
public, final, & static they must be declared with an initializer(=) (methods are implicitly public) |
|
If a field in an interface(a constant) is changed, what value will the dependent classes see? |
the updated value |
|
A class can implement how many interfaces? Extend how many parent classes? |
implement MANY extend ONE |
|
what is a prerequisite to be able to use a for each loop |
"list" must implement the ITERABLE interface |
|
what is a field? |
an attribute of an OBJECT or THE CLASS |
|
what is a method? |
an operation on an OBJECT or THE CLASS |
|
what is static vs non static? |
static is 'of the class': (static field) one memory location/value shared by all objects of class non-static is 'of the/an object' |
|
Variables: what is an instance variable? class variable? local variable? |
instance variable: non-static fields in a class declaration Class variables: static fields in a class declariation local variables: variables in a method or block |
|
what may only access static fields and call other static methods? can be called using the class name |
static methods |
|
what is a good rule of thumb for scope of a variable? scope is visivility (think teleSCOPE) |
the variable is usable from the point it is declared to the end of the block |
|
public void (int x) { } is this legal? |
nope |
|
example of field hiding |
|
|
what is "this" |
reference to current object |
|
when does an object of reference type die? |
when there is nothing pointing to it! |
|
what is the output |
42 -1 the address is sent - x points to the first location of the array list - a then points to the first location of the array list a can then modify the value without. notice this way you can modify an array without having to have a method return anything does not work on int, Integer, double, Double.. |
|
definition of encapsulation and why its important. |
encapsulation is hiding information and methods that completes a task so that an end user experiences only the final output and does not have to worry about how the computation took place. This is good in team settings when programs get large and chunks of code need to be abstracted to a single line. |
|
difference between access modifiers: public? private? protected? |
public: fields/methods can be accessed from outside the class (NO restriction) private: fields/methods can NOT be directly accessed from outside the class protected: seen in class, subclass (even if subclass is in a different package) , same package |
|
what is a checked exception |
- needs to be caught/handled before compilation time - reminder from compiler to programmer about potential failure state - subclass of Exception ex: IOException, DataAccessException |
|
What is an Unchecked Exception |
- not checked at compile time. - generally programming error ex: lovely NullPointerException ArrayIndexOutOfBounds - subclass of RunTimeException |
|
convention for access modifiers |
field are private, can have getters/setters methods are public |
|
can you have an ArrayList (of primative types)? |
no! however, can have ArrayList Integer being the wrapper class for int |
|
.length() is for ? .lenght is for ? |
- String.length(); int[] d = new int[3]; - d.length; |
|
in sub-class constructor... |
super is called first, implicitly if not specified think: the parent must exist before the child, to make the parent, then create child |
|
True/False In one constructor method, you can call both - super() and -this() |
False! |
|
instance of operator |
all objects are instances of Object |
|
what is the call stack? |
- Each method is a frame. - Each frame holds storage for parameters and local variables of the method. |
|
syntax of a basic try/catch block.. |
- 'Exception' is a class name this one is just catching the most generic exception which is Exception |
|
what does a method do 'syntatically' when it doesnt want to handle the exception, but pass the problem to someone else , like an incompetent ******* |
|
|
what is needed to write ones own exception? |
|
|
what is the trend in catch blocks? |
specific to general |
|
Finally clause.... |
executes no matter what!
|
|
domain decomposition |
a way of splitting up tasks with threads in which the same code processes different sub-domains |
|
task decomposition |
a way of splitting up task with threads based on nature of the task one thread handle graphics in GUI other thread handle backend code |
|
if we have, Thread t; t.join() does what? |
blocks the CURRENT THREAD until thread t completes.
is generally in try/catch for InterruptedException |
|
|
important that threads synchronize on same object example , if threads are of one class have a class variable, private static Object gatekeeper = new Object(); |
|
thread state map |
|
|
importance of buffering |
decreases amount of read calls necessary. reads 'more than needed' important to flush buffers! |
|
FileOutputStream |
low level I/O handles: raw data, byte-oriented |
|
DataOutputStream |
High level I/O handles: java primitive types |
|
ObjectOutputStream |
Object I/O handles: java objects |
|
DataOutputStream and ObjectOutputStream need to build off? |
- FileOutputStream takes file as arguement - Data/Object output takes FileOutput obj as arguement |
|
. class is compiled version of .java |
.class in not human readable .java is |
|
read/write from a text file |
read: BufferedReader r = new BufferedReader(new FileReader(file object)); write: PrintWriter w = new PrintWriter(new FileOutputStream( new File ("filename"))); |
|
Internet Protocol |
128.10.2.21 identifies host a computer |
|
Domain Name System |
maps 128.10.9.143 to data.cs.purdue.edu |
|
Transmission Control Protocol |
identifies ports on hosts for a network connection |
|
Socket |
Ip address + TCP port house + streetname |
|
how many sockets make a connection? |
2 |
|
Servers wait for connection |
One physical device can be both server and client, at different times |
|
ServerSocket has .accept() method that waits accept returns a Socket object |
kool |
|
to implement server with many client connection. And avoid blocking client connections |
use threads |
|
|
|
|
|
|
|
if we wanted to downcast a3 from Animal to Bird, what must be done to make sure this will not yield errors? |
|
|
In dynamic binding, the method called depends on the... dynamic binding occurs during... |
class of the object referenced runtime (overriding methods, dynamic binding) |
|
Animal myanimal = new SongBird(); is myanimal.sing(); legal? |
NO! animal does not know how to sing |
|
Animal myanimal = new SongBird(); is myanimal.move(); legal? |
Yes, but interestingly SongBird does not have a move method so we go up the inheritance hierarchy and find that Bird overrides the move() so "flying" would be printed, or something |
|
In static binding, the method called depends on the ... static binding occurs during |
class of the variable compilation time |
|
output? |
inside Collection sort method because variable type was of Collection |
|
String s = "Guybrush"; s.substring(2,4) = ?? |
"yb" stop at 4-1 |
|
what happens if your exceptions are listed generic to specific? |
compilation error, unreachable code |
|
|
know |
|
|
in javax.swing modal - wait until closed to continue program JFileChooser |
|
Dynamic Data Structures offer.... |
fluidity
|
|
Abstract Data Type |
- exhibit a behavior, dont know how implemented -stack -queue ex: stack implemented via linkedList or array |
|
stack |
-pop -push -isEmpty Last In First Out |
|
queue |
- add - remove - peek ex print queFirst In First Out |
|
break the problem down into two pieces - basis case: - recursice case: |
recursion |
|
recursion |
watch out for how many frames are made proxy method to call recursive method |
|
traversing a binary search tree |
|