1/38
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Dynamic Typing
Language infers ‘types’ at runtime (python)
Static Typing
Languages check ‘types’ before code is run
Void
Nothing is returned but code will run like usual (the method name main is the return type of this method)
Compilation
Intermediary “code translation” step that happens before code runs
during this step the compiler check types (and other things) and performs optimizations on your code
Primitive Types (8 in Java)
int, double, char, boolean
Expressions
A unit of code with a type/ value
literals: int, double, boolean, char
variables: int age = 27
using operator: 27 * 12
method calls: static int daysToMinutes(int days)
Statement
A unit of code that describes an action executed for its side effect.
assignment statements: int x = 7; // stores RHS value into LHS container
Primitive type coercion
Primitive types can be coerced (modified) either through implicit widening or explicit casting.
implicit (widening): 3 + 4.0 → 3.0 + 4.0 → 7.0
explicit (casting): 7/2 → 3 (truncated division)
(double) 7/2 → 3.5
(double)(7/2) → 3
Runtime Stack
When a method is called in Java, space is allocated for its parameters and local variables in a region called the…
Call Frame
Created when a method is called and deleted when that method returns.
Variable declaration
int hours;
Variable definition
hours = 24 * days;
Variable initialization
int minutes = 60 * hours;
Static
used to declare a “free function” (is not tied to a particular instance of a class)
Classes
The basic building blocks of Java programs are…
Methods
code subroutines
Type
The (static) type of a variable characterizes the set of possible values (or states) that it can be assigned, and the ways that it can be used within the program.
Local Variables
Stored in call frames on the runtime stack.
Object
an instance of a non-primitive type.
Reference Types
Non-primitive types in Java
All types beyond the 8 primitive types in Java are reference types
Instances of reference types are called objects.
A reference type is defined by a class
Heap
Where objects of reference types are allocated
Instance Methods
operations defined within a class that can be called on an object of that class.
The behaviors of reference types are primarily specified by defining instance methods within their classes
Null
indicates the absence of an object reference; a reference type variable that is null does not have an arrow pointing to any object on the heap.
String Literal
the sequence of characters of the String we are creating, writing
Array
a data structure with a fixed capacity that stores elements of a particular type in an ordered, linear arrangement of cells.
Index
a number used to identify a specific cell in an array.
Specification
The specifications of a unit of code (for example, a method, a class, or a field) are a description of the intended behavior of that code.
Implementer
An implementer(s) of a unit of code (a method or a class) is a developer who provides the definition of that code
Client
a developer who calls that code from within code that they are writing.
Pre-Condition
a property that must be true when a method is called.
Most often, these are requirements on the values of input parameters or the states of objects that they reference.
Post-Condition
a property that will be true when the method returns.
These include properties of the method's return value as well as any side effects of the method.
Defensive Programming
the implementer actively turns pre-condition violations into runtime errors using assert statements.
Unit Testing
a small unit of code (e.g., a single method or class) is tested in isolation.
Checks are performed against this unit of code to ensure that it conforms to its specifications.
Test-Driven Development
use specifications to develop unit tests for a piece of code that is not yet written and use these unit tests to guide the method's development.
Glass Box Testing
some implementation details are used to inform the design of unit tests, particularly to ensure good test coverage.
Black Box Testing
tests are written using specifications of a method and not based on any internal implementation details of the methods/classes.
Time Complexity
the number of basic operations that its code performs, expressed as a function in terms of various parameters of its input size.
Space Complexity
the maximum amount of memory that is allocated at one time during the execution of the method beyond the space of its input parameters.