UML Diagrams
Important Words
Interfaces and Classes
Special Methods
JAVA Collection Frameworks (JCF)
100

What does UML stand for?

Unified Modeling Language

100

What does the final keyword mean?

It makes an attribute or method non-changeable. 

100

How are interface implementation represented in a UML diagram? How are class implementation represented in a UML diagram?

Interfaces - dotted line with open arrowhead

Classes - solid line with open arrowhead

100
What does toString() method do?


It defaults to Object's toString() unless overridden and is used to print attributes of of the object

100

What is the time complexity for 

1. appending elements to the end of an ArrayList

2. checking if an ArrayList contains a certain element (worst case)

3. appending element to the front of an ArrayList

O(1)

O(n)

O(n)

200

What are the 3 parts of a UML class box?

1) Class name

2) attributes and their types

3) method names with return types and parameters

200

What does the keyword static mean?

The same variable or method can be accessed without creating an object of the class (i.e. variables exist at the class level, not object level)

200

What is the keyword to implement an interface? What is the keyword to implement a parent class?

implements and extends

200

What does equals() do and write out an equals() on the board :)

1. Check if the Object parameter is an instance of your object

2. Typecast the Object parameter into your object type

3. Return a boolean expression (using == for primitive and .equals() for objects )

200

What is the time complexity of

1. inserting element into a HashSet

2. seeing if an element is contained in a HashSet

O(1)

O(1)

300

What does the word public mean?

Can be accessed and modified by the same class, subclasses, and other classes

300

What does Polymorphism mean?

The condition of occurring in several different forms

300

How do subclasses access private attributes from a superclass?

- use getter methods, such as super.getName();

- when you override a method from a super class make sure to use the EXACT same method header

300

What is the purpose of a hashCode() and write one out on the board :)

- to return a unique hashcode value for the object

- if you consider two objects to be equal they must have the same hashcode

public int hashCode(){

       return this.name.hashCode() + this.id

300

What is the time complexity for 

1. adding an element to a TreeSet

2. removing an element from a TreeSet

3. accessing an element in a TreeSet

All have O(logn)

400

What does the word private mean?

Can be accessed and modified by the same class only 

400

What does the word Overloading mean? 

Two method have the same name but different parameters

Overriding is different than overloading. Overriding is when a subclass has the same method as the parent class, but you want the subclass' version to be implemented

400

What can/cannot an interface do?

- Cannot be instantiated

- Can only contain method signatures and static fields

- Everything must be public

- is-a relationship

400

What is the purpose of compareTo() and come up and write the the method on the board :)

-takes in 1 argument

-from the Comparable interface

-returns an int: <0 if this is lesser / =0 if this and o are equal / >0 this is greater

-located in the class

-uses natural ordering

400

What is the time complexity for

1. accessing the value in a HashMap

2. adding a value to a HashMap

All O(1)

500

What does the word protected mean?

Can be accessed and modified by the same class and its subclasses

500

What does Encapsulation mean?

The bundling of data with the methods that operate on the data into a class. It reduces program complexity

500

 What is the difference between an interface and an abstract class?

-Interfaces do NOT have any implementation, while abstract classes do. Abstract class only need to have one method abstract which must be implemented by the subclass using the @Override

500

What is the purpose of compare() and come up and write it on the board :)

-takes in 2 arguments

-from the Comparator interface

-returns custom ordering

-located in a separate class

500

What are the differences between TreeMap, TreeSet, HashMap, and HashSet?

HashMap - unordered, key-value pair

HashSet - unordered, value

TreeMap - ordered, key-value pair

TreeSet - ordered, value