Exceptions
I/O
Threads
Networking
GUI
100

What type of exception is a ClassCastException and when does it occur?

A ClassCastException is a Runtime Exception and it occurs when an object cast into another object that the object isn't.

100

What are the four types of I/O?

Reader and Writer and InputStream and OutputStream.

100

What is the function that needs to be implemented when working with Threads and what is the function that is called to make the Threads work concurrently?

Run

Start

100

What is a network?

The term for the software and hardware that allows computers to communicate.

100

True or False: GUI's run on the same thread as the main thread?

False

200

What is the difference between a Runtime Exception and a Checked Exception?

A runtime exception doesn't have to be caught or thrown explicitly in the syntax and is an Unchecked Exception.

200

What is a decorator pattern?

When an object takes in another object to expand its functionality.  

200

What are the two ways to make a Thread in Java?

Extending Thread and implementing Runnable.

200

What is a ServerSocket and what parameters are needed to make one?

The ServerSocket opens a network on the provided port which other sockets can connect to.

200

What method is used to run the GUI and what order of methods are called after that?

Application.launch(args);

init, start, close


300

What is the syntax to throw an Exception with the message "sup".

300

Write the line of code to create a PrintWriter to System.out. If you can also make it so the PrintWriter auto flushes when it encounters a new line then you get double points.

PrintWriter pw = new PrintWriter(System.out, true);

300

What is it called when two threads are stuck waiting for the other one wake it up?

Deadlock

300

How does a server connect to a client? Not just the method but also how the method works.

The server calls the accept() method. This then causes the thread to wait until a Socket connects.

300

Which methods do you call to set the elements of a BorderPane?

setTop, setLeft, setCenter, setRight, setBottom

400

What is the difference between an Error and an Exception?

An Error shouldn't normally be handled. They can be handled just like Exceptions, except they probably shouldn't because it is very difficult to recover from and it isn't a hundred percent sure when they occur.

400
Create a BufferedReader that reads from System.in.

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

400

What happens when wait and notify is not called in a synchronized block of code? What exception can be thrown when wait() is called?

IllegalStateMonitorException


InterruptedException

400

What is the difference between TCP and UDP?

TCP - Guarantees data is sent and received and is slower

UDP - Is faster but data might not reach and might not reach in the same order they are sent

400

Write the code that when a button is clicked then the function runButton is called.

button.setOnAction(e -> {

runButton();

});

500

What is the output of this function?

500

Why did you learn IO and exceptions in the same week?

IOExceptions are often thrown when working with IO and IOExceptions are Checked Exceptions. It is impossible to learn IO without first learning Checked Exceptions.

500

What is synchronized?

synchronized is the keyword to allow only one thread into the section of the synchronized code.

500

Write code that connects to a server with the hostname: "localhost" and the port number 25565 and then creates the BufferedReader and PrintWriter to talk to the connected socket.

Socket client = new Socket("localhost", 25565);

BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));

PrintWriter writer = new PrintWriter(client.getOutputStream(), true);

500

Which tier usually creates the model tier and why?

The View Tier, because it needs to add itself as an Observer.