???
Java Classes
Interfaces
Abstract Classes
JCF
100

(T/F) In UML class diagrams, the same kind of arrow is used when a class refers to an interface it implements, and when it refers to another class the original class extends


False


100
What keyword is used to reference the field of the class?

this

100

What keyword do you need to have a class make a "contract" with an interface?

implements

100

What class is the default abstract class that gets extended?

Object

100

What two functions must be overridden to use a HashSet or Hashmap?

int hashcode();

boolean equals(Object o);

200

In what two situations is toString automatically called?

System.out.println();

String Concatenation

200

What is a Constructor and are they mandatory?

A constructor is a method and sets the fields and creates a new object of the type of that object. It doesn't need a return type and is not mandatory. 

200

How many Interfaces can you implement with one class?

Infinite

200

What problem in coding does abstraction solve?

Duplicate code due to common behavior between classes.

200

What is something you must do in order to use a tree set with the object's natural ordering and a user set order?

Natural Ordering: make the object comparable and implement its function.


User set order: make a comparator and implement its function

300

What key words are used for each of these arrows?

Extends

Implements

Extends

300

What keyword should all of your fields be and why?

private

Other classes should not have access to your fields.

300
What keyword is used to say that a variable cannot be changed?

final

300

You can instantiate an abstract class, True or False.

False

300

Time Complexity for contains for these three classes:

TreeSet, HashSet, ArrayList

TreeSet: O(log(n))

HashSet: O(1)

ArrayList: O(n)

400

Make a HashSet to store Strings.

Set<String> madeSet = new HashSet<>();

400

Write a Java class about a book.

3 fields: name, price, author

3 methods:getName, getPrice, equals

400

What keyword is used to declare a method but leave the implementation to the child classes?

abstract

400

If a parent class has a constructor with parameters, what must a child class do and what keywords are necessary?

The child class must call the parents constructor with its parameters with the super keyword.

400

What is the signature for implementing Comparable and Comparator for an object Person by age, assuming it has a method called getAge. 

Comparable:


Comparator:

500

Given an abstract class with no declared fields and all abstract methods, why not just use an interface? When would you want to use an interface or abstract class?

Abstract:   When you want access modifiers beside public + classes that inherit from abstract class are all closely related

Interface:   When you expect wide array of classes will implement + take a class can implement multiple

500

What is static?

Static methods and variables don't belong to the object but to the class. Don't need an object of that type to use static methods or variables.

500

What is a generic type? Give an example of a generic class declaration with type parameter.

Generic class or interface that is parameterized over types 

Example of generic class: 

public class Box<T> {  }

500

Write an Abstract Class for a Person:

3 fields: name, age, alive

6 methods:

Constructor: default alive

getName, birthday, speak, cook

toString: form: "Person{name='Kevin', age=20, alive=true}"

500

Daily Double!!!!

Try and draw the entire JCF. Whichever team draws the most accurate and biggest picture of the JCF wins this point and probably the game.



M
e
n
u