What is a method signature? Give an example.
The method name followed by the param list that gives the name and type for each param. E.g. - public void inviteFriend ():
What is a NullPointerException?
Happens when you try to call an object method on an object variable with a null value. Usually means the oject was created without the new operator followed by the class name and ().
What is a static/class method? How is it different from a non-static/object method?
A static method is one that doesn’t need to be called on an object of a class. Object methods need to be called on an object of a class.
What operator do you use to run an object’s method?
The dot operator (.), the object, method name, and ending parenthesis. Eg. - yertle.forward()
What is procedural abstraction?
Allows a programmer to use a method by knowing generally what it does. Like how you can drive a car without knowing how the breaks work
What do void methods return?
Nothing; the point of calling it is to have an effect (do things)
What do non-void methods do?
They return a value the code carrying the method call can use; the value returned tells us about the object’s internal state (produce values)
What is an accessor (getters)?
A method that accesses a value in an object, takes no arguments, and has a non-void return type (almost always starts with get, like getWidth)
What is a return statement (in a method)?
It returns the value output from the method, and must match the declared return type of the method. The calling method then uses that value.
What is a package?
The parent class of a class (For the String class, its in the java.lang package). Every class knows its parent class (superclass)
How do you cause implicit conversion of values to string values?
You concatenate them with a string object (“String” + nowAString + “String”)
List the escape sequences and what they do.
Within quotations, \” prints a quote, \\ prints a backslash, and \n prints a new line
What is an index?
A number associated with a string’s position. It begins at 0. One less than the length of a string (length starts at 1)
int length()
the number of characters in a string
String substring(int from, int up to but not including)
a new string that is a part of another string with 0 to all characters copied from the original string
immutable
doesn't change index the position of a character in a string
int indexOf(String str)
Returns the position of one string in another or -1
int compareTo(String other)
Returns a number to indicate if one string is less than (-difference), equal to (0), or greater than another (positive difference) (draw a greater or less than to find out)
Boolean equals(String other)
Returns true if the characters are the same, false otherwise
toString
Returns a string representing the object that is passed to this method
equals
Returns true if the characters in two strings are the same
Math.random() returns a random number between…
0.0-0.99.
What formula moves the random number into a range starting from a minimum number?
(int)(Math.random()*range) + min
How do you find the range?
max number - min number + 1
(int)(Math.random() * (max - min)) + min
write the permutation code