Unit 2 vocab Flashcards
class
defines a new data type. It is the formal implementation, or blueprint, of the attributes and behaviors of the objects of that class.
object
a specific instance of a class with defined attributes. Objects are declared as variables of a class type.
constructor
code that is used to create new objects and initialize the object’s attributes.
new
keyword used to create objects with a call to one of the class’s constructors.
instance variables
define the attributes for objects.
methods
define the behaviors or functions for objects.
dot(.) operator
used to access an object’s methods.
parameters (arguments)
the values or data passed to an object’s method inside the parentheses in the method call to help the method do its job.
return values
values returned by methods to the calling method.
immutable
String methods do not change the String object. Any method that seems to change a string actually creates a new string.
wrapper classes
classes that create objects from primitive types, for example the Integer class and Double class.
new
is used to create a new object.
null
is used to indicate that an object reference doesn’t refer to any object yet.
String(String str)
Constructs a new String object that represents the same sequence of characters as str.
int length()
returns the number of characters in a String object.
String substring(int from, int to)
returns the substring beginning at index from and ending at index (to -1). The single element substring at position index can be created by calling substring(index, index + 1).
String substring(int from)
returns substring(from, length()).
int indexOf(String str)
returns the index of the first occurrence of str; returns -1 if not found.
boolean equals(String other)
returns true if this (the calling object) is equal to other; returns false otherwise.
int compareTo(String other)
returns a value < 0 if this is less than other; returns zero if this is equal to other; returns a value > 0 if this is greater than other.
int abs(int)
Returns the absolute value of an int value (which means no negatives).
double abs(double)
Returns the absolute value of a double value.
double pow(double, double)
Returns the value of the first parameter raised to the power of the second parameter.
double sqrt(double)
Returns the positive square root of a double value.