General Programming Flashcards
What is a nested class?
Any class whose declaration occurs within the body of another class or interface
What is a top-level class?
Any class that is not nested
What is a bytestream?
A sequence of bytes
What is a byte?
8 bits (each bit a 1 or 0)
What is a class declaration?
The first time the compiler is made aware of the existence of the class. Declaration does not require definition. class X; // valid Java class declaration Sometimes called a prototype
What is a class definition?
Includes the parameters, extensions, implementations etc that define what a class is. This is also the declaration unless the class has already been declared without a definition
What is a class signature?
All the parts of the class definition required at runtime for overload resolution
What is the difference between call by need and call by name?
Call by need = lazy evaluation = memoized
Usually only used if argument(s) are pure (free from side effects).
Call by name
Arguments are not evaluated before the function is called; they are evaluated each time the argument is used in the function body.
What is functional composition?
When a function manipulates the return value of another function.
What is a first class function?
A function can be passed as an argument to another function.
What is delegation?
Delegation means that you use an object of another class as an instance variable, and forward messages to the instance.
eg class Printer { RealPrinter p = new RealPrinter void print ( ) { p.print ( ) }
Delegate = RealPrinter.print( ) Delegator = p, the instance of the object providing the delegate.
What is the difference between: Member Attribute Variable Field
Member : Normally used to define the variables and methods.
Attribute : Attributes are the instance variables of an Object.
Variable : Primitive variables and Objects reference variables as instance or local variables.
Field: Field marks an instance variable.
What is the difference between synchronous and asynchronous execution?
synchronous - wait for task 1 to finish before beginning execution of task 2.
Like being in a queue to be seated in a restaurant. One at a time.
asynchronous - can start task 2 before task 1 finishes execution. Task 2 is usually executed on a separate thread, but does not have to be.
Like being seated in a restaurant - ordering, serving, clearing away is happening to everyone all the time.
NB Simply put, these definitions are the opposite in CS from everywhere else these terms are used