1/45
WIP
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
Attributes
Instance variable, properties of object. Ex: Class = dog, attributes = color, breed, age
Behavior
methods (ex: turnLeft() )
Case sensitive
Uppercase vs - lowercase. HELLO is diff than hello
Run-time error
logic error, ex in painter there is a paint command but they are out of paint
Variable
attribute
Primitive type
predefined. no capitalization. int, double, char, boolean.
Parameter
variable in method constructors ex: color in public void paint(String color){
Argument
value of the parameter. ex: “white” in painter.paint(“white”);
Void method
does not have a return type, instead does an action.
Encapsulation
combining data and functions, etc, into one class. Basically using private with get and set methods
Constructor
Public method for instantiating an object. Ex: public Dog(int age, String breed){
Truncation
int divided by an int slices off the decimal instead of rounding
Concatenation
slapping to strings together. Can use +=
int/0 vs double/0
double will return infinity, int will make your planes explode
compound assignment operator
shortcuts. +=, -=, *=. Ex: if int a = 4, a+= 6 will yield 10. same as a = a + 6
mod operator
%. gives you the truncated remainder
casting
assign a value of one type to another. Ex: int num = (int) 5.2; //num is now 5
math random
(int)(Math.random() * range) + min
object class
superclass
toString()
to return an object in string format to be readable. Ex: public String toString(){ return variable + “ “;}
escape sequences
\n = new line, \\ = backslash, \” = double quote
parsing
dividing texts into different parts w/substring
.compareTo
returns the int value of subtracting the two strings
class methods
can be called without creating a class object
instance methods
method that requires an object of a class to be created to be called
static
in class methods
overloading
defining two or more constructors with the same name but different signatures
iteration statement
statements that repeatedly perform a block of code. Ex: while
selection statement
statements that perform a block of code once under certain circumstances. if statements
demorgans laws
!(A && B) = !A || !B. !> is <=, !< is >=, vise versa
alias
a different name assigned to the same object. They are strings that are ==
non alias
different objects with the same name. These use .equals
for loops
(ex:) for(int i = #; i<#; i++){code}
abstraction
condensing/simplifying, like classes with constructors being created in a class, or assigning variables names like int age = 76 for ex
accessor methods
get() method
mutator methods
set() method
reference variable
an object created with all its attributes being its own thing when stored as an object.
shadowing
local (private) variables shadow global (public) variables with the same name. Basically just giving it a default I guess
returns character index
.charAt()
see if one string has the same sequence of characters
.contains()
find number character is at
indexOf()
find last number character is at
.lastIndexOf()
get actual length
.length()-1;
floor
floor(x), rounds down, returns double
ceiling
ceil(x), rounds up, returns double
== vs =
== for checking something (returning a boolean). ex: if(a == b). = for setting equal