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;
41 Cards in this Set
- Front
- Back
***class file
|
-The JVM translates a class definition into a format a java compiler understands - class file
-Contains JVM instructions, symbol table, and other instructions |
|
***JVM is a stack-based
|
stack-based abstract computing machine
|
|
***ClassLoader
|
Java-supporting web browsers have a subclass of ClassLoader that can load class files over the Internet
|
|
***JVM allows no byte-level access
|
Direct operations for allocating objects, invoking methods, and accessing fields
|
|
***bytecodes
|
A class file contains JVM instructions, which are called bytecodes
|
|
***verification
|
-One of the most distinctive features of the JVM
-ensures that class files loaded in memory follow certain rules and guarantee that programs cannot gain access to field and methods -cant trick JVM into doing something unsafe |
|
***Class area
Java stack Heap Native method stacks |
-code and constants
-"activation records" or "stack frames" -this is where objects live |
|
***<T> void copy(List<T> src, List<? super T> dest)
{ ... dest.add(src.get(i)); ... } List<Object> lo; List<String> ls; Is each of the following true or false -copy(ls, lo); -copy(lo,ls); |
-True
-False |
|
***Assume B<T> <: A<T> and Integer <: Number
True (safe) or false (unsafe) -B<Integer> <: A<Number> -B<Integer> <: B<Number> -B<Integer> <: A<Interger> -For any T, B<T> <: B<?> |
-False
-False -True -True |
|
***Suppose that p and q are Haskell parsers. Give an informal explanation of p +++ q
|
If p succeeds it behaves as parser p, otherwise it behaves as parser q
|
|
***Thread can be in one of the following states:
-new -runnable -running -blocked -dead |
-new: just created, not yet started
-runnable: after invoking start() - not scheduled to run yet -blocked: waiting for a resource, sleeping for some set period of time. When condition met, returns back to runnable state -dead: after return of run method, cannot be restarted |
|
*** What values, evaluate to?
-(\x y -> x == y) "not" "false" |
-False
|
|
***What types?
- (1:2:3:[]) |
- Num a => [a]
|
|
*** What types?
-map (\x -> [x]) "abc |
-[String]
|
|
***T/F
-Haskell functions are all total functions |
-False
|
|
***T/F
- omit x = 0 keepGoing x = keepGoing(x + 1) the following code will not terminate (or eventually crash) omit ( keepGoing 5) |
-False
|
|
***T/F
-In Haskell, any function with two or more arguments can be used as an infix operator (enclosed in back quotes) |
-True
|
|
***T/F
-In Haskell, function application has the highest priority |
-True
|
|
***T/F
-Haskell's laziness is what helps guarantee referential transparency |
-False
|
|
***T/F
-In a pure functional language, evaluation order affects the value of the computation |
-False
|
|
*** What values, evaluate to?
-let filterOut p xs = filter (not . p) xs in filterOut odd [1..5] |
-[2,4]
|
|
*** What values, evaluate to?
-((foldr (*) 1) . map (+2) . (filter odd)) [1..4] |
-15
|
|
*** What values, evaluate to?
-foldr (++) "" ["Answer", "Is", "Yes"] |
-"AnswerIsYes"
|
|
***What types?
-map (\x -> [x]) |
-[a] -> [a]
|
|
***What types?
-(.) f . g = \x -> f (g x) |
- (b -> c) -> (a -> b) -> (a -> c)
|
|
***What types?
-\x y -> x == y |
-Eq a => a -> a -> Bool
|
|
***T/F
-In Haskell, a type can be dynamically inferred at run time |
-False
|
|
***T/F
-All regular grammars are also context-free |
-True
|
|
***
_ Step produces a stream of tokens from a stream of characters |
-Lexical analysis
|
|
***
_ Step is essentially undoing abstractions. The result of this step must be executable by some target machine |
-Code generation
|
|
***
_ Step transforms the annotated syntax tree into another tree that will result in a more efficient executable code in the end |
-Optimizing
|
|
***
_ Step generates a syntax tree from a stream of tokens |
-Syntactical analysis
|
|
***
_Step annotates syntax tree with types, checking that types are used correctly |
-Type checking
|
|
***
Order: Code generation, Optimizing, Type checking, Syntactic analysis, Lexical analysis |
-Lexical, Syntactic, Type checking, Optimizing, Code
|
|
*** F-bound
<T extends Movable> T translate(T m) { return m.move(1, 1); } |
interface Movable<T> { T move(int x, int y); }
<T extends Movable<T>> T translate<T>(T m) { return m.move(1, 1); } |
|
***F-bound
Assume the following interface: interface Comparable { bool eq(Comparable); } <T extends Comparable> bool noteq(T t, T u){ return !t.eq(u); } Define a class MyInt which is Comparable: class MyInt extends Comparable { bool eq(MyInt) { . . . }!// not a valid override bool eq(Comparable) { . . . } // meaningless comparison } |
interface Comparable<T> { bool eq(T); }
<T extends Comparable<T>> bool noteq<T>(T t, T u){ return !t.eq(u); } class MyInt extends Comparable<MyInt> { bool eq(MyInt) { . . . } } |
|
Fill in
|
|
|
***
Explain what a parser is |
-A parser takes a text (composed of tokens) and determines its syntactic syntax
|
|
*** What is returned by the following?
failure "parse this" |
[]
|
|
** What happens in the monadic parser
p >>= f if p fails? |
[]
|
|
***
Three ways to obtain a Class object |
-From instance (using Object.getClass()):
MyClass mc = new Myclass(); Class c = mc.getClass(); -From type: c = boolean.class; -By name: Class cls = null; try{ cls = Class.forName("MyClass"); } catch (ClassNotFoundException e) { ... } //use cls |