Exam Preparation Elliot Flashcards

(47 cards)

1
Q

Benefits of AWT

A

Good for background system specific code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Benefits of Swing

A

Lightweight, pure java, subclass of AWT Frame

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a JOptionPane

A

Popup box with Y, N, and Cancel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the general structure of. JMenuBar

A

JMenuBar(JMenu(JMenuItem))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Was is JFrame a subclass of, and what is it not a component of

A

AWT.frame, JFrame is not a Component

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a general overview of MVC

A

View passes input to Controller, Controller updates the View

Controller changes the state of the Model

ModelChanged by the Model updates the values in the view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What parts are in the event dispatch thread

A

Event Queue, Event Loop, Event handler (click > data received > refresh the gui), GUI components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What part is in the helper thread and where does it send its data

A

Long task processing, this will add to the event queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an event source

A

A component generating an event (“fires”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an event

A

A user interaction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an eventListener

A

An object implementing a handler to react to an complete a task (listeners need to be registered to a source)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the general form of a listener

A

JObject created
name.addActionListener(new actionListener() {
override ActionPerformed(actionEvent e) {
name.method();
}
});
add the object to the panel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the mouse listener called

A

MouseMotionListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between Adaptors and Listeners

A

Listeners are interfaces, Adaptors are abstract classes

Adaptors only require implementation of the required events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the general form of an adaptor

A
panel.add(new MouseAdaptor() {
    override the MouseMoved(MouseEvent arg0) {
        doStuff...
    }
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the Event dispatch thread do

A

Executes GUI code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the three reasons to have the Event dispatch thread

A

Responsive, long computations won’t lock up the GUI

ThreadSafe, only the EDT can access the GUI

Swing can use SwingWorker to deal with computational tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How to use SwingUtilities, what will this ensure

A

Use invokeLater on runnable as a parameter to start the GUI, this will ensure GUI is on the EDT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the general form of SwingUtilities

A
SwingUtilities.invokeLater(new Runnable() {
    public void run() {}
});
20
Q

What is the general form of SwingWorker

A
SwingWorker worker = new SW() {
    override doInBackground()
21
Q

What are the four main regex methods

A

compareTo(), substring(), indexOf(), matches()

22
Q

How does compareTo() function

A
  • if value alphabetically before, + if alphabetically behind, 0 is match
23
Q

File I/O text

A

Format with Formatter(format), BufferedWriter

Scan with Scanner and scanner methods hasNext(), nextLine(), next(), BufferedReader

24
Q

Binary file I/O class and methods

A

DataInput/OutputStream; read/write Byte, Int, Double

25
Steps to be able to serialize
Class has to implement Serializable Wrap non serialisable by overriding read/writeObject Unserializable fields will need to catch IOExc
26
Why use threads
Efficient, responsive, allows for task separation
27
Compare processes and threads
Processes spawn threads, have a call stack, PC, and their own memory Threads have a class stack and a PC and share the memory of their parent process
28
Why can threads be faster
Threads can be separated onto multicore systems
29
What are the six main thread states
``` waiting timed waiting blocked terminated ready running ```
30
What does the OS control in regards to threads
Switching between ready and running
31
Thread waiting methods
wait(), notifyAll(), sleep()
32
Thread Blocking methods
enter/exitSync()
33
Compare threads and runnable
Both need a run() method Extend thread, implement runnable You can extend another class with runnable Runnable has a lower overhead due to a single runnable instance
34
What are Daemon threads
Service, background threads, will auto terminate once main has terminated
35
What is ExecutorService
A means of reusing threads
36
What are the types of thread pools
newFixedThreadPool(int), newCachedThreadPool()
37
What are the main ExecutorService methods
execute(runnable) shutdown(), orderly kill sequence shutdownNow(), kill and halt, return a list of shutdown threads, no guarantees awaitTermination(), block invocation until everything is complete
38
What does synchronised do
Creates a lock on method declaration, only one tread can access the method at one time (Instance monitor lock) note that unsynchronised methods with be accessible
39
How can we avoid producer/consumer issues
Use synchronised and implement checks before allowing method/value access
40
What is the BlockingQueue
It is an array(int) which stores pending operations
41
What are the main BlockingQueue methods
add (illegalStateExc) put (will wait if no space in queue) remove (returns the head, NoSuchElementExc) poll (return the head) note BlockingQueue ignores FIFO
42
What is Callable and what does its method return
An interface with a single call() method returning the result of a threads task, an exception if task incomplete
43
What is the general format of Callable
``` public class SimpleCall implements Callable { override String call() throws Exception { return String datarow = "A bunch of values"; } } // Asynchronous result ```
44
What is the Future object
Obj represents a result of an asynchronous computation
45
What are the main Future methods
cancel(boolean interrupt) throws InterruptedException isCancelled() return true of task sent and interruptedException isDone() return true if task is complete get(optional timeout) wait for completion and return result
46
What are the Future exceptions
Cancellation, computation canceled Execution, computation threw an exc Interrupted, thread interrupted while waiting
47
How to use FutureTask
Implement the future interface | call the get method of callable