Vocab Flashcards
Wrapper class
Wrapper classes provide a way to use primitive data types (int, boolean, etc..) as objects.
Use the capitals: Int not int
Autoboxing
automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes
this
refers to the current object in the method or constructor
new
used to create a new instance of a class
Static variables
variables lifetime is the full time the program is running
Static method
-method belongs to the class not the instance of the class
-method is accessible to every instance of a class but methods defined in an instance are only able to be accessed by that object of the class
Instance variables
variable which is declared in a class but outside of constructors, methods, or blocks
Instance Constants
variable whose value never changes
Polymorphism
ability of a class to provide different implementations of a method, depending on the type of object that is passed to the method
Inheritance
create new classes that inherit features of the superclass
super
constructor call
super.method()
call parent method
default access
same class and same package
private access
only that class
protected access
Same class, same package, and different package subclass
public access
yes
abstract class
restricted class that cannot be used to create objects
abstract method
-no body
-can only be used in an abstract class
interface
-a completely “abstract class” that is used to group related methods with empty bodies
-may not have member variables or method definitions
typecast
assign a value of one primitive data type to another type
instance of
test whether the object is an instance of the specified type (class or subclass or interface)
abstract class vs interface
Abstract classes can have methods with implementation whereas interface provides absolute abstraction and can’t have any method implementations.
Enumerated Types
type whose legal values consist of a fixed set of constants
ex)fall winter spring summer
Array
int[] myNum = {10, 20, 30, 40};
myNum[2];
arr = insertX(n, arr, x, pos);
Array list
ArrayList<Integer> arrlist = new ArrayList<Integer>(5);
arrlist.add(15);</Integer></Integer>
Iterated for loop
for (Integer number : arrlist) {
System.out.println(“Number = “ + number);
}
Map
Map<Integer, String> map = new HashMap<>();
map.put(1, “One”);
map.get(Object key_element)
Set
Set<Obj> set = new HashSet<Obj> ();
s.add("Welcome");
s.remove("Welcome");</Obj></Obj>
next vs nextLine()
nextLine() - returns all text up to a line break
next() - returns tokenized text. The next() method uses whitespace as the default delimiter.
throw vs throws
throw - throw an exception explicitly (one) throws - declare multiple exceptions, separated by a comma
@test
says the next method is a test
@Before vs @BeforeClass
@Before - executed before each test
@BeforeClass - runs once before the entire test fixture
UML ——->
shows dependence
UML <——->
shows association
UML ____> (solid line arrow)
connects a specialized element with a generalized element
(inheritance)