GUI and Events Flashcards

1
Q

How do you declare a generic class in java?

A
class myClass {
...
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you make wildcard extend a super type?

A

extends T>

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

How do you make wildcard a supertype of a specific class?

A

super T>

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

How do you implement selection sort?

A
  1. repeat i times -> n
  2. find the smallest element in the sub set {n, i - 1}
  3. Move this element to position n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the run time complexity of selection sort?

A

O(n^2)

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

How do you implement insertion sort?

A
  1. repeat i-1 times -> n
  2. Itterate backwards through the sub set {0, n - 1} -> z
  3. If the element z is greater than element n continue itterating
  4. Otherwise, insert the element at position z + 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the runtime complexity of insertion sort?

A

O(n^2)

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

How do you implement bubble sort?

A
  1. Repeat i times -> n
  2. repeat n - 1 times -> z
  3. If element z is greater than element z + 1 swap the two elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the runtime complexity of buble sort?

A

O(n^2)

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

What is the runtime complexity of merge sort?

A

O(n log n)

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

How do you create a checked exception class?

A

make it extends Exception

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

What is the superclass of unchecked exceptions?

A

Error

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

How do you create a printwriter for a file?

A
File fName = new File(...);
PrintWriter myPrintWriter = new PrintWriter(fName);
myPrintWriter.println(...);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What exception should be caught when opening files?

A

IOException

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

How do you read data from an internet source?

A
URL url = new URL("www.mysite.com");
Scanner data = new Scanner(url.openStream());
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you create a new file reader in java

A

FileReader(File file) or

FileReader(String fileName)

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

What exception should you handle when creating FileReader

A

FileNotFoundException

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

What exception should be handled with PrintWriter

A

FileNotFoundException

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

What exception occurs when there is an arithmetic error?

A

ArithmeticException

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

What exception is thrown when an out of bound array location is accessed.

A

ArrayIndexOutOfBoundsException

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

What exception is thrown when referencing a null object?

A

NullPointerException

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

What exception occurs when out of bound string location is accessed?

A

StringIndexOutOfBoundsException

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

What interface must event handlers implement?

A

EventHandler

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

How do you use a lambda expression in java?

A

(param1…, paramn) -> action

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How do you create an anonymous inner class?
new myInterface() { // code};
26
how do you get the button from mouse event?
getButton()
27
How do you get the key character from a KeyEvent?
getKeyChar()
28
How do you get the key code from a KeyEvent?
getKeyCode()
29
How do you get a string desribing KeyCode
KeyEvent.getKeyText(int keyCode)
30
How do you add a child to an element?
(element).getChildren.add(node)
31
How do you add all nodes?
addAll(node1, node2, ...)
32
How do you determine if a point is in a node javafx?
conatins(double localX, double localY)
33
How do you get the id for a node?
getID()
34
how do you display a stage?
show()
35
what methods must be included in javaFX Applications
public void start(Stage primaryStage)
36
How do you create a new scene
Scene myScene = new Scene(component, x, y)
37
How do you get the source of an ActionEvent
getSource()
38
How do you set on action button?
setOnAction
39
What is a pane?
basic place to store components
40
What is a Stack Pane?
Stacks components on top of eachother
41
What is a flow pane?
Places row by row then overflows to next column or vise versa
42
What is a border Pane
places nodes in specific regions
43
What two methods must be implemented when using the setADT?
``` int size(); boolean add(T elt) ```
44
How do you create an exception with a message?
Exception(String message)
45
How do you get if iterator has next item?
hasNext()
46
how do you get item form iterator?
next()
47
how do you remove the current item in iterator?
remove()
48
How do you preform an action on each remaining item in itterator?
forEachRemaining(Consumer super E> action)
49
What does the iterable interface do?
It allows it to be used in a for each loop.
50
How do you return the iterator element from an interable interface.
iterator()
51
What methods must elements of hashSet override?
hashcode() and equals()
52
What is the complexity of basic retrieval operations in treeSet?
o(n)
53
What is the retrieval time for HashSet?
constant time
54
What is the map interface header?
Interface Map K - Key type V - Type of mapped value
55
how do you clear a map?
clear()
56
How do you check if map contains key?
containsKey(Object key)
57
How do you check if map contains value?
containsValue(Object value)
58
How do you get an object by its key?
get(Object key)
59
How do you returns the set of keys from a map?
keySet()
60
how do you map an element to a specified key?
put(K key, V value)
61
How do you add multiple elements to map?
putAll(Map extends K, extends V> m)
62
How do you remove an object from map?
remove(Object key)
63
How do you replace a key in a map?
replace(K key, V value)
64
how do you get the size of a map?
size()
65
What are the functions of a hashMap?
``` void get(Object key) void put(K key, V value) void remove(Object key) boolean remove(Object key, Object value) ```