Exam 2 Flashcards

(133 cards)

1
Q

PTUI

A

Plain text user interfaces - command line interfaces

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

GUI

A

Graphical user interface - comprised of graphical controls

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

GUI toolkit used in class

A

JavaFX

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

Java’s original GUI toolkit

A

Abstract Window Toolkit - OS specific. Used heavyweight windows

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

Java Swing

A

GUI added in v. 1.2. lightweight and platform-independent.

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

GUI using JavaFX begins by __ the __ __.

A

Extending, Application class. Application is abstract.

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

The ___ is a window in which the JavaFX application runs

A

Stage

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

T/F: A stage is used to display a scene

A

True

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

T/F: Only one stage can exist at a time.

A

False. Additional stages show as separate windows. Primary is auto-created with start method

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

Scenes contain __, which can be __ or __

A

Single control. Widgets (button, label, text). Pane (container for other controls).

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

The graphical element that is the building block of a GUI

A

Control aka node

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

Control used to display a string of text

A

Label

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

JavaFX controls are highly __

A

Customizable

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

Some basic modifications to a label

A

setText(String)
setFont(Font)
setPadding(Insets)

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

Common stage sets

A

stage.setTitle(String)
stage.setScene(scene)
stage.show()

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

Controls can be customized __ and through the use of __

A

Programmatically. Cascading style sheets (CSS)

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

Layout

A

Container in which nodes can be added. Determines where the nodes are, including position and size. Layout is also a node.

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

Layout that arranges children from left to right

A

HBox

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

Layout that arranges children from top to bottom

A

VBox

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

To add children to an HBox or VBox

A

box.getChildren.add(Node)

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

T/F: HBox and VBox layouts automatically fill in extra space by default

A

False. Only use space each child needs. Use setMaxHeight(Double.POSITIVE_INFINITY) or width to adjust widgets

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

A __ method contains code to build some product

A

Factory. Anything that stays the same between outputs is placed in method. Changing factors in parameters.

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

Insets

A

Used to define extra space on the top, bottom, left, and right of something. Can be used within padding setting to achieve.

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

CornerRadii

A

Used to round corners on otherwise rectangular shapes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Border
Drawn around outside edges of a component
26
BorderPane
Divided into five regions: top, bottom, left, right, center. One node each max (last kept if multiple)
27
T/F: An empty region in a BorderPane will be invisible
True
28
GridPane
Organizes children into columns and rows (col first). Exact num doesn't need specifying on instantiation.
29
T/F: In a GridPane, children can only exist in one location (col, row)
False. Nodes can expand using additional arguments on add method gp.add(label, 3, 4, 1, 2)
30
TextField
Control in which user can type single line of text. Can include prompt text.
31
Button
Control that users can interact with using the mouse or keyboard. Created with text or image. Responds to mouse events (enter, exit, hover, click)
32
Trying to set a background for a button will...
Remove its default highlights and shading
33
Observer Design Pattern
When there is a subject of interest, it maintains a list of observers that will be notified when something happens.
34
EventHandler
An observer interface that must be implemented by classes that want to be notified when an event occurs on a JavaFX control.
35
When using event handler, the real type that replaces the T must ...
Extend the Event class. handle (T) called when event of interest occurs
36
ActionEvent
Used for button interaction. Button is subject. Observers must implement EventHandler. Can use button.setOnAction(EventHandler) to register to be notified
37
Image
Used to load and display images
38
Ways to load an image
1. String URL, starting with "file:..." 2. An InputStream
39
ImageView
Control just for displaying images. Cannot be added directly to a scene. Must have a parent.
40
StackPane
Stacks children one on top of the other in order added. Can be used to create a composite image.
41
Media
Class that represents an audio or video file. Source may be internet address or file in local system
42
Used to play media
MediaPlayer. Does not have a visual component
43
T/F: Labels can also be used to display graphics
True. Can set where image sits in relation to text
44
Grow Priority
Used for HBox and VBox to determine if child nodes will grow horizontally or vertically (respectively) to fill in extra space
45
Architecture
High level design that determines how the classes in a system are organized
46
MVC
Model View Controller is a pattern used when creating applications with user interfaces.
47
In MVC, the model
Basic building blocks of the app. Core elements and any logic needed to maintain or update the state of the application
48
In MVC, the view:
Part of the app the user can see. Represents current state of the model. Updated as model changes.
49
In MVC, the controller:
Core application logic. When input provided, it determines how to translate this action to the model. May also update the interface.
50
In GUIs some or all of the controller logic is often ___
Embedded in the GUI
51
A background can be set to an image using
BackgroundImage. If smaller than the control, image can be repeated
52
Practice of writing code that is executed in response to events is referred to as __
Event-Driven Programming
53
Abstract Data Type
Describes the behavior of data structure from user perspective without implementation details
54
Data Structure
Grouping of related data (elements)
55
Queue
First in, first out (FIFO). No random access.
56
A data structure that has at least one field of its own type is __
Recursive. Used to build linked sequences.
57
Components of a Node
Value of some type (content) Reference to the next node in the sequence (could be null)
58
In a node sequence, the first node is the __ and the last is the __
Head. Tail. Tail's next is null.
59
A queue should be implemented as a __ and has the following operations:
Interfaces. Enqueue Dequeue Size (Front, back, is empty) Optional
60
In a node-based queue composed of a single node, that node will be ___
The front and back
61
In a node-based queue, the __ node is the front and the __ is the back
Oldest. Newest.
62
T/F: In a node-based queue, if a dequeue is performed, the new front is changed to the old front's next node.
True
63
An array-based queue can use a __
Circular array. If indexes of front or back reach the end, they wrap around to the beginning
64
In an array-based queue, when an element is enqueued, it is added at the __ index, which is then incremented
Back
65
When does a circular array need to be resized?
When the size is equal to the length of the array before an enqueue
66
In an array-based queue, when dequeuing, the __ index is returned and the index is incremented
Front
67
In an array-based queue, the value at the index being dequeued should be __ before the index is incremented
Set to null
68
How to handle dequeue on an empty queue
Return null OR Throw an exception
69
T/F: In an array-based queue, after a resize, the indexes stay the same for the head and tail
False. Head will be set to 0 and tail will be set to size.
70
Time complexity for queue operations
O(C). Worst is for array when it needs to be resized, which is rare (O(N))
71
Space complexity: node vs array queues
Creating node object for every element uses more memory than array, but arrays queues usually over-allocate memory.
72
Generic Type
Declares one or more type parameters between angle brackets. When variable declared, a real type is specified in place of each type parameter.
73
Generic Class
Class that uses a generic type
74
Trying to use a different type after a variable is declared with a real type on a genetic type will cause ...
A compiler error
75
T/F: A generic type can't use its own type parameter when declaring variables of a generic type.
False. Generics can be combined.
76
T/F: A type parameter cannot be used within the body of a class unless it is declared as part of the class.
True.
77
Two options when extending/implementing a generic type
1. Make the new class generic as well public class A extends B 2. Make the new class only work with a specific real type public class A extends B Will lose flexibility with second
78
T/F: Generics only work with reference types
True. Cannot use primitive types without autoboxing
79
Autoboxing
Translating from a primitive type to a wrapper class (int to Integer)
80
Unboxing
Translating from a wrapper class to a primitive type (Integer to int)
81
List operations
Append Get Set Size (Insert and Remove optional. Would cause shifting)
82
T/F: Lists maintain elements in order added
True
83
Lists closely resemble a __ array
Dynamically sized
84
An array list is created with an array of ___ that are then ___
Objects. Cast to other types Object[] things = new Object[10]; things[0] = anyValue; Object obj = things [5]; T thing = (T)obj;
85
Array lists keep track of
Capacity and size Resize when size equals capacity
86
Method to copy an array
Arrays.copyOf(orig, size)
87
Linked list keeps track of
First node - head Last node - tail Size Similar to linked nodes, but uses indexes to search, get and set.
88
Array List time complexity
O(C) O(N) for append when need to resize array. O(N) for any shift operations in middle of list
89
Linked list time complexity
Append, get, set, insert, remove at head or tail, O(C). Anything in middle of list, O(N)
90
Java for-each loop
for(int element : an_array)
91
Iterator
Returns each element in a data structure in some sequential order. Defines basic methods used by for-each loop
92
T/F: An iterator is guaranteed to return each element in the sequence exactly once.
True
93
A data structure must implement the __ interface and return a working __ to work with for-each
Iterable. Iterator.
94
T/F: An interface can extend a class
False. An interface can only extend another interface
95
An interface may provide a ___ of one or more of its methods
Default implementation
96
If a class implements an interface but doesn't provide an implementation of a default method ...
The default implementation is used by default
97
Default method typical use
For adding methods to an existing interface to avoid compilation errors in existing classes
98
JCF
Java Collections Framework. Java's unified architecture for representing and manipulating collections.
99
Collection frameworks contain three things:
Interfaces defining abstract Data structure Implementations of interfaces Methods provide useful algorithms
100
JFC Queue method names for enqueue and dequeue
Offer and poll
101
JFC's Stack iterates __
Backwards (bottom to top)
102
Non-empty binary tree comprises at least one __
Node
103
Leaf
A node whose left and right subtrees are both empty
104
Internal node
A node that is not a leaf
105
Root node
Has no parent node
106
Visiting each node in a tree is referred to as...
Traversing the tree
107
Infix Traversal
Nodes are visited left, middle, right. Would get values in increasing order. Also called in order traversal
108
Binary trees are __ data structures
Recursive
109
General search process for binary trees
If target is the root, return true. Else go down the left or right subtrees (if not null) and search for target. If not found at all, return false.
110
Search complexity of a binary tree
O(N). On average, half of the nodes need searching.
111
Binary Search Tree
Left subtree is only values less than parent. Right is only values more than parent.
112
Binary Search Tree searching algorithm
Same as binary tree, but uses value of target to determine which subtree to go down
113
A binary tree should be __ and its subtrees __
Balanced. Bushy. Approximately same number of nodes in both halves at every level
114
Unbalanced trees are more __
Branchy than bushy
115
An extremely unbalanced tree becomes __
A list
116
Complexity of searching a BST
Depends on how balanced the tree is. A balanced tree O(log2N). An unbalanced tree approaches O(N)
117
A type is made naturally comparable by ...
Implementing the Comparable interface.
118
Comparable
Generic interface that defines type parameter T. Class usually subs its own type. Uses compareTo(T other) method.
119
Comparator
Helper class that can be used to sort objects that don't have a natural order or need to be sorted another way.
120
A comparator class will ...
Implement Comparator. Uses the compare(T a, T b) method
121
Heap
Binary tree in which each node is of equal or lower priority than that of its parent. Root has highest priority.
122
T/F: In heaps, the horizontal order of nodes matters
False. Only the relationship between child and parent matters in terms of priority.
123
Min-heap/Max-heap
Organizes values from smallest to largest/largest to smallest
124
T/F: Priority is determined by the programmer
True. Based on the problem statement
125
Heaps can be created using an __ on an array
Overlay. Root is index 0 k is the index of a node where 0<=k
126
If a value added to a heap is higher priority than its parent...
Values are swapped. Swap continues until value in correct position. Called sifting up.
127
The __ is always removed from the heap
Root. The rightmost node on the bottom level becomes new root. Values sift until priority is correct.
128
Worst case time complexity for adding to heap
Standard is O(C), but O(log2N) if value needs to sift all the way up
129
Worst case time complexity for removing from heap
Standard O(C). If value needs to sift all the way down O(log2N) length of the tree
130
TreeSet and TreeMap are unique in that they...
Keep elements/keys in sorted order. Require comparable elements or a comparator. Perform slightly slower as a result.
131
Red-Black Tree
Self-Balancing BST. Elements moved around to maintain balance. Guaranteed O(log2N) for search, insert or remove
132
HashSet and HashMap provide __ performance for all basic operations
O(C)
133
TreeSet/Map should only be used over HashSet/Map when...
The elements must be maintained in sorted order