Object Oriented Programming 2 Flashcards

1
Q

Rich API support

A

Doing / learning networking, parallelism, graphics, GUI, algorithms

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

Why is java platform independent

A

It runs in a virtual machine: JVM

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

Why learn Java?

A

Active development, many jobs, platform indep, tools (networking, …)

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

Java and Distributed Systems

A

Socket communication, thread management, object serialization, remote method invocations, servlets, applets

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

Java compilation

A

Programm compiled into bytecode, which the JVM executes at runtime

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

Object

A

Combines methods (behaviour) and data (state),
hide complexity, modularization, modelling of domain

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

How are objects defined

A

throught the keyword “class”

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

“volatile”

A

ensures visiblity accross threads, safe to use across threads

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

Interface

A

Defines a group of methods, classes implement them to provide functionailty, implementation enforced at compilation

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

static nested classes

A

no access to outer members, to hide access

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

Named constants

A

entirely in uppercase with underscore

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

Creation of Arrays:

A

anArray = new int[10];
float[] anArrayOfFloats;
int[] anArray = {
100, 200, 300,
400, 500, 600,
};

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

Casting

A

Cast allows access to specific object
methods

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

Defensive copies

A

gainst outside failures, ill-behaved clients, or attacks
also for getters

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

varargs

A

represent zero or
more arguments of a specified type

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

Parallelism (concurrency)

A

one computer that does multitasking, real (processors) or pseudo (threads)

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

Distributed system

A

Networked components, coordinated by messages

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

Server threads

A

within server process; handle concurrent user requests

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

Server processes

A

handle different types of access
(e.g., web, mail, file, …)

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

Remote Invocation

A

Client invocation and server result
RPC (remote procedure call) or RMI (remote method invocation)
Requires defined messaging protocoL

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

Server State:

A

 Stateful (client tables)
 Soft state (for given time)
 Session state (for session)
 Stateless

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

Thread-based Connection Abstraction

A

incoming request -> accepted by dispatcher thread

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

Threaded Server Design Patterns

A

Fix or dynamic number of threads
Re-usage of threads: thread pool (created at start), non active threads kept in pool

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

Thread per Request

A

dispatcher reveives request, for each a thread is created or assigned from pool
Worker thread:  Read request
 Process request
 Answer request
 End

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

Thread per Connection

A

Dispatcher Thread assigns client to thread
Worker thread
 Read request
 Process request
 Answer request
 Wait for next assignment or return to pool
(if client closes connection)

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

Thread per Service-Object

A

Each service-object provides
 An own thread
 An own queue
Dispatcher assigns request to service object queue
Service object thread reads from queue and processes -> queue serialization

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

Java Threads

A

JVM runs as a process on the operating system
JVM runs several threads (garbage collector, …)
Java.lang.Thread objects are placed into own threads
“run()” must be overridden

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

DON’T use Thread.sleep() for synchronization

A

Exact time when thread will be resumed is difficult to predict:

sequence and duration of thread execution varies, and may vary for different runs

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

Interface Runnable

A

Alternative to using run on objects derived from Thread

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

Synchronization

A

shared data, execution order ofter hard to predict
without controls, we cannot predict thread switch

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

Synchronization methods are needed

A

data consistency (data correctness)
maintain parallelism

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

synchronized keyword

A

locks an object, if a thread encounters it and it is locked, thread is put to sleep
try to synchronize specific variables

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

End of Java Thread

A

join(): blocks until a thread ends
yield(): increase probability to switch to another thread

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

Inside synchronized

A

wait() → blocks a calling Object until it gets notified that it can resume
notify() → unblocks waiting caller
notifyAll() → unblocks all waiting callers

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

JavaFX

A

Stage: window
Scene: container to fill a stage

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

Observers in JavaFX

A

implements the interface EventHandler<ActionEvent></ActionEvent>

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

Properties in JavaFX

A

Classes which implement the observer model
They can be observed
contains: values, methods to register observers, methods to update and read the observed value
Informs all registered observers

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

JavaFX Bindings

A

Mechanisms to couple properties -> Change of one property changes another property (uni or bidirectional)

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

JavaFX Collections

A

You can register observers to collections
They are notified on changes to the collection
Interfaces ObservableList, ObservableMap, ObservableSet

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

JavaFX Elements

A

“Node” is the basic element
Pane derives from Node and is basis for all container classes

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

Container Classes derived from Pane

A
  • VBox: Vertical layout
  • HBox: Horizontal layout
  • FlowPane: Line by line layout
  • BorderPane: top/bottom/left/right/center
  • StackPane: on top layout
  • TilePane: uniform grid layout
  • GridPane: variable grid layout
  • AnchorPane: anchor to border
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

JavaFX Interaction Elements

A

Control class derived from Node
Labels, Buttons, Lists, Pickers, Slider, Text Input

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

JavaFX Other functions

A

Automatization: Stylesheet support, UI definitions from FXML files
Multi-windows UIs
Web and media support

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

JavaFX MVP

A

Model
 Application logic (data and methods)
 Independent of GUI
View
 GUI component creation and manipulation
 Different views may represent parts of the model
Presenter
 Flow control
 Triggered by UI interaction and using/manipulating model

45
Q

JavaFX Problems in Event Processing

A

Certain action on an Event may take long time. No other events are processed during this time, so no
window update happens.
Solution: Aim for short duration in event handling, use Threading for event handling
Submit the update to the event queue of the JavaFX Application thread using Platform.runLater()

46
Q

Interface Worker

A

 Observe state
 Possibility to cancel

47
Q

Class Task

A

Implement a single long running task
* message (ReadOnlyStringProperty)
* title (ReadOnlyStringProperty)
* value (ReadonlyObjectProperty<V>)
* workDone (ReadOnlyDoubleProperty)
* State (ReadonlyObjectProperty<Worker.State>)</Worker.State></V>

48
Q

class Service

A

Implement repeating tasks

49
Q

Class ScheduledService

A

Schedule of repeating tasks, coordination via properties

50
Q

8 Golden Rules GUI/Application Design (Ben Shneiderman)

A
  1. Strive for consistency.
  2. Enable frequent users to use shortcuts.
  3. Offer informative feedback.
  4. Design dialog to yield closure.
  5. Offer simple error handling.
  6. Permit easy reversal of actions.
  7. Support internal locus of control.
  8. Reduce short-term memory load.
51
Q

Wired Network types:

A
  • PAN: Personal Area Network (USB)
  • LAN: Local Area Network (Ethernet)
  • MAN: Metropolitan Area Network (DSL)
  • WAN: Wide Area Network (IP Routing)
52
Q

Wireless Network types:

A
  • WPAN (Bluetooth)
  • WLAN (Wifi (IEEE 802.11))
  • WMAN (WiMAX (IEEE 802.16))
  • WWAN (GSM; UMTS; LTE, 5G)
53
Q

Circuit Switching:

A

“plain old” telephone system

54
Q

Packet Switching

A

compute shortest path, longer messages partitioned into packets

55
Q

Virtual Circuit (Frame Relay):

A

determine routing path during setup

56
Q

Broadcasting (e. g. WLAN):

A

No switching, all messages delivered to all nodes, receivers must make sense
of messages, collision detection mechanisms are needed.

57
Q

Routing

A

Distributed Algorithm
Routers work cooperatively
Aim to compute the shortest paths
Required routing protocol

58
Q

Congestion Control

A

Avoid overload
Trade-off latency vs. throughput

59
Q

Internetwork

A

Integration of heterogeneous sub-nets
Unified protocol (e.g., Internet Protocol IP)

60
Q

ISO-OSI 7 Layer Model

A

All People Seem To Need Data Protection
* Application
* Presentation
* Session
* Transport
* Network
* Datalink
* Physical
NOT used in practise

61
Q

Internet Protocol IP

A

Virtual Network, Allows routing through multiple networks

62
Q

TCP/IP (Transmission Control Protocol/Internet Protocol)

A

Only contains 4 of the 7 OSI Layers.
DataLink and Physical layer are combined to Host-to-Network layer (LAN)

Network layer → IP
Transport layer → TCP (or UDP)
Application layer → FTP, DNS, SMTP

63
Q

Ports

A

for distinguishing two connections on a host.

64
Q

TCP/UDP Protocol

A

TCP is connection-oriented, handles order, loss, duplicate packets, Bi-directional, has to be connected to IP
UDP is connectionless, only for short messages, unidirectional, IP given in message

65
Q

UDP/TCP Realization in Java

A

Packages java.net java.io
InetAddress
– represents an Internet host by IP address and name
DatagramPacket and DatagramSocket
– used to communicate with UDP
– send one packet at a time
Socket und ServerSocket
– to establish TCP connection
– send data using InputStream and OutputStream

66
Q

Broadcasting

A

Target are all nodes in the network

67
Q

Multicasting

A

Receiver can select if it is a member of the group or not
multicast IP address range
Sender does not know who are the receivers

68
Q

java.io

A

InputStream, OutputStream
 Byte-oriented streams
Reader, Writer
 Character-oriented streams

69
Q

Semaphores

A

used to limit the access to critical sections of code (data), not only among threads, it is also used among
different processes by OS
Counter to limit number of parallel accesses

70
Q

Reader/Writer Problem

A

Write access must be exclusive while read access can be shared
Prioritize writers if updates are frequent
Prioritize readers if high read throughput and rare updates

71
Q

synchronization in Java

A

synchronized; wait/notify
semaphore implementations
custom data structures

72
Q

Transactions

A

Abstraction of set of operations (e.g., of a client) into atomic unit
All-or-nothing execution
No interference from other concurrent transactions or server/client crashes (other process cancels transaction)

73
Q

ACID Properties for Transactions

A

Atomicity
 Transaction executed all or nothing
Consistency
 Transactions transform objects from one consistent state to another
Isolation
 Transactions performed without interference of other transactions
Durability
 Result of successful transaction is permanently stored

74
Q

Serial Equivalence for Transactions

A

Serial execution (with immediate, permanent write) gives correct state
two conflicting operations have to operate on same objects in the same order
locking, optimistic control, timestamp ordering, nested transactions

75
Q

Locking

A

is pessimistic
Exclusive locks
Read/write locks (read shared, write exlcusive)
Two-phase locking

76
Q

deadlock

A

If two transactions wait for each other to release a lock it can end in a deadlock, as both are waiting and
can’t proceed.

77
Q

Deadlock prevention

A

Acquire all locks at beginning of transaction
lock need may not be known in advance at beginning

78
Q

Deadlock detection

A

Maintain wait-for-graph
Test for cycles on each operation, or periodically

79
Q

Optimistic Concurrency Control

A

Assume conflicts are sparse
Working phase, validation phase, update phase

80
Q

Stream Terminal Processing

A

Traverse (forEach)
Search (allMatch, anyMatch)
Reduce (count, sum, average)
Collect (toArray)

81
Q

Indirect Communication

A

Temporal/spacial decoupling (async, hide identity)
communication middleware
Persistent communication
distributed systems: frequent changes, nodes (dis)connect frequently, nodes unknown

82
Q

Transient Communication

A

Transient async: A sends and continues, message can only be sent if B runs
Transient receiver oriented: A continues only upon message reveival is acknowledgedment (issued immediately)

83
Q

Persistent Communication

A

Persistent asynchronous
store on sender side
Persistent synchronous
store on receiver side

84
Q

Push Notifications

A

Distributed systems often need updates on local object changes (events)
Useful to connect heterogeneous systems
Efficient notification via multicast

85
Q

IP multicast

A

eliver IP packets to multiple destinations
Minimize number of packets sent
Packets do not delay each other

86
Q

Implementations for Group Communication

A
  • Integrity of message content
  • Guarantee of delivery to each client
  • Receiving order
  • Interface to add/remove clients, update list
  • Monitoring of recipient status, remove inactive recipients
87
Q

JGroups

A

Reliable group communication in Java
Has a Protocol Stack with underlying communication protocols
Channels with basic functionality for joining, leaving, sending, receiving (send via reliable multicast)

88
Q

Message Queues

A

Reliable point-to-point communication
persistent storage of messages
Decoupling of space and time
Sender sends messages to waiting queue destined for a recipient
FIFO or priority

89
Q

Publish-Subscribe

A

sends (publishes) structured events to an event service (broker)
Clients subscribe topics, get notified when event available
Event characterized by type and attributes
One-to-many communication
Publishers und subscribers typically do not know each other (space uncoupling)

90
Q

Publish-Subscribe Type of delivery

A

 Direct: Point to point, Multicast
 Indirect: Message Queue, Server

91
Q

Publish-Subscribe Subscription Models

A
  • By Channel
  • By Topic
  • By Content
  • By Type
92
Q

Distributed Shared Memory

A

Parallel computing architectures → Multiprocessor shared memory
Compute-intensive operations on data partitions
Avoids explicit messaging
Needs memory protection: Use locks and semaphores

93
Q

Tuplespaces

A

Distributed Shared Memory = Distributed Random Access Memory
Tuple Space = Distributed Associative Memory (content-adressable memory)
 Asynchronous publish-subscibe system
Tuple = Message with ordered and typed attributes
 Tuplespace = temporary database of tuples
Data producers that publish and subs that consume based on a pattern (<String, Int, “hello”>)

94
Q

Explicit messaging

A

No communication transparency
Explicit marshalling
Explicit send/receive of messages
Explicit exception handling

95
Q

RPC / RMI

A

Middleware connects caller and remote procedure
No explicit marshalling required
No explicit send/receive required
Exception handling

96
Q

JAVA RMI

A

Middleware service which allows access to remote JAVA objects (other PC on network, localhost)
Client-server communication without need to use sockets
Modular development
Load balancing

97
Q

Stubs and Skeletons

A

Stub code provides object access to the client who
uses a remote object (“Remote control” to remote object
)
Skeleton code manages object requests by the
object server

98
Q

RMI Registry Usage

A

Server side: bind / rebind / unbind (name, e.g. “Counter”)
Client: lookup
Registry runs objects in own threads
Can create multiple stubs for parallel access to server objects

99
Q

Pass as Value / as Reference

A

by value: safe from outside manipulation, store a copy
by reference: callbacks to passed object (side effects), provided by stub

100
Q

RMI Design patterns

A

indirect communication mechanisms (tuple spaces, queues, …)
distributed MVP applications (with RMI interface)

101
Q

Object Migration with RMI

A

process of moving objects between RMI servers
Pass object using call-by-value
copy placed on the server
copy is exported
Applications: load balancing, object validation, persistent storage
Clients may use derived classes > server needs to reload, client needs to publish via codebase server

102
Q

Web-based Application Programming

A

integration of code with the existing client/server infrastructure
Document-oriented (sync: html, forms or async: dom)
or webservice-oriented

103
Q

How to Process HTTP Interaction Requests on the
Server Side?

A

Java servlets

104
Q

Java Servlets

A

Handling client requests
Derive a Servlet class from HttpServlet
Overwrite the methods doGet and/or doPost
Create HTML code or Java Server Faces in servlet and deliver

105
Q

Execution of Servlets

A

Typically, web servers serve requests multithreaded, d, but create only one object for each Servlet
Requires synchronization of Servlet access
Servlets can share information via Servlet context
run long-lasting Servlet jobs asynchronously (startAsync, AsyncContext)

106
Q

Identification of Servlet clients

A

getRemoteAddr() (not reliable, due to use of proxies and NAT)
getSession() creates session ID (cookie) to identify returning client

107
Q

Java Server Faces (JSF)

A

Use external HTML code templates defined in XHTML
Embed input/output fields in the XHTML page using Expression Language (EL) statements
Fields linked to objects

108
Q

AJAX

A

Asynchronous JavaScript and XML
Embed JavaScript (JS) code in webpages, run by browser
code sends the data to the Servlet
receives a reply and updates an element of the webpage
Programmatic updates to webpages via DOM

109
Q

Webservices

A

provide services based on HTTP protocol which may exchange data
SOAP (Simple Object Access Protocol)
REST (representational state transfer)
e.g. JSON (JavaScript Object Notation)