Java Programming: I/O Streams, Collections Framework, and JavaFX GUI Development

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

flashcard set

Earn XP

Description and Tags

Comprehensive practice flashcards covering Java I/O streams, JavaFX GUI architecture, controls, layout panes, event handling, and the Java Collections Framework.

50 Terms

1
New cards

What is stream I/O in Java?

Stream I/O is a mechanism that transfers a flow of data between a source (such as a keyboard, file, or network) and a destination (such as a console, file, or network).

2
New cards

How do Byte Streams and Character Streams differ in Java?

Byte Streams read and write data as 8-bit8\text{-bit} bytes for binary data (images, PDFs, audio) using base classes InputStream and OutputStream. Character Streams process text characters and handle encoding/decoding using base classes Reader and Writer.

3
New cards

What value is returned by the read() method of InputStream when the end of the stream is reached?

It returns −1-1.

4
New cards

What is the primary role of the File class in the java.io package?

The File class represents the path of a file or directory and provides methods to verify existence, inspect metadata, create, delete, and list directory contents.

5
New cards

What is the difference between the mkdir() and mkdirs() methods of the File class?

mkdir() creates a single directory, whereas mkdirs() creates the directory along with any necessary but nonexistent parent directories.

6
New cards

Which classes in java.io are used for serializing and deserializing Java objects?

ObjectOutputStream is used to serialize and write objects, and ObjectInputStream is used to read and deserialize them.

7
New cards

In JavaFX, what is a GUI control and which package contains most standard controls?

A control is an interactive, ready-made UI component placed inside a Scene to interact with the user; most controls reside in javafx.scene.control.

8
New cards

How do TextField and PasswordField differ in JavaFX?

TextField accepts a single line of unmasked plain text, whereas PasswordField masks the entered characters for privacy and security.

9
New cards

How does user selection differ between a CheckBox and a RadioButton?

A CheckBox represents an independent option that can be selected or cleared regardless of other checkboxes, whereas RadioButtons are grouped via a ToggleGroup to enforce mutually exclusive single-option selection.

10
New cards

What capability distinguishes ComboBox from ChoiceBox in JavaFX?

ComboBox supports text editing and custom user entries via setEditable(true), whereas ChoiceBox is a simpler choice control that does not support editable text entry.

11
New cards

How is multiple selection enabled in a JavaFX ListView?

By configuring its selection model using: list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

12
New cards

How are progress values passed to a JavaFX ProgressBar?

Progress is set as a double value ranging from 0.00.0 to 1.01.0, or set to ProgressBar.INDETERMINATE_PROGRESS to indicate unknown or ongoing progress.

13
New cards

Which class from the Java standard library does the JavaFX DatePicker control use to represent dates?

java.time.LocalDate

14
New cards

What are the distinct roles of getText(), getValue(), and isSelected() in JavaFX controls?

getText() retrieves displayed text as a String; getValue() retrieves the selected or entered object value (used by ComboBox, ChoiceBox, DatePicker); and isSelected() returns a boolean indicating whether a toggle or checkable control is active.

15
New cards

What is the primary function of a layout pane in JavaFX?

A layout pane is a container node that automatically positions and sizes child nodes (controls and shapes) and rearranges them during window resizing.

16
New cards

How does the base Pane class position child nodes compared to managed layout panes?

Pane provides free-form coordinate positioning using explicit coordinates (layoutX, layoutY, or relocate()), rather than automatically arranging nodes into rows, columns, or predefined regions.

17
New cards
<p>Which JavaFX layout pane divides the interface into the five regions shown in the diagram?</p>

Which JavaFX layout pane divides the interface into the five regions shown in the diagram?

BorderPane, which divides the available container space into Top, Bottom, Left, Right, and Center regions.

18
New cards

How does StackPane lay out its child nodes?

StackPane places child nodes on top of each other in a centered stack where later added children render above earlier children.

19
New cards

What is the difference between FlowPane and TilePane?

FlowPane wraps child nodes to the next line or column based on individual element sizes, whereas TilePane assigns each child node an identical, uniform tile width and height.

20
New cards

How does AnchorPane position its child nodes?

AnchorPane pins child nodes to the pane edges by specifying anchor offsets (top, bottom, left, or right), allowing nodes anchored on opposing edges to resize dynamically.

21
New cards

What is the root interface for the Java Collections Framework (excluding the Map hierarchy)?

java.util.Collection

22
New cards

What are the defining characteristics of the List interface in java.util?

List maintains insertion order, allows duplicate elements, allows null elements, and provides zero-based index access to elements.

23
New cards

Why are ArrayList iterators described as fail-fast?

If the list is structurally modified at any time after the iterator is created (except through the iterator's own add or remove methods), the iterator immediately throws a ConcurrentModificationException.

24
New cards

How does Vector differ from ArrayList?

Vector is a synchronized, legacy class that is thread-safe for individual operations, whereas ArrayList is unsynchronized and not thread-safe by default.

25
New cards

Which class does java.util.Stack extend, and what constructor does it provide?

Stack extends Vector and provides only a zero-parameter constructor.

26
New cards

How do HashSet, LinkedHashSet, and TreeSet differ regarding ordering and null elements?

HashSet provides no ordering guarantees and permits one null; LinkedHashSet preserves insertion order and permits one null; TreeSet maintains sorted order using a red-black tree and prohibits null elements under natural ordering.

27
New cards

How do the two sets of Queue methods (add/remove/element vs. offer/poll/peek) differ when an operation fails?

add(), remove(), and element() throw an exception on failure, whereas offer(), poll(), and peek() return a special value (false or null).

28
New cards

What internal data structure does ArrayDeque use, and are null values permitted?

ArrayDeque uses a resizable circular array, has no capacity restrictions, operates in amortized constant time, and strictly prohibits null elements.

29
New cards

What ordering does Java's default PriorityQueue implement, and does iteration display elements in sorted order?

It implements a min-heap where the smallest element has the highest priority; iteration does not guarantee sorted order, but polling always retrieves the head element with the highest priority.

30
New cards

Why is the Map interface considered separate from the Collection interface in Java?

Map manages key-value pairs where keys must be unique and map to at most one value, rather than managing a collection of individual elements.

31
New cards

How do HashMap, LinkedHashMap, and TreeMap differ in terms of ordering and lookup performance?

HashMap offers O(1)O(1) average lookup with no ordering guarantees; LinkedHashMap offers O(1)O(1) average lookup while preserving insertion order; TreeMap provides O(log⁡n)O(\log n) operations while maintaining keys in sorted order.

32
New cards

What is the Properties class in java.util, and which class does it extend?

Properties is a synchronized class extending Hashtable used to manage application configuration settings as string-based key-value pairs that can be loaded from and saved to files.

33
New cards

How do Comparable and Comparator differ in Java?

Comparable defines natural ordering within the class itself via compareTo(T o), while Comparator defines external custom sorting logic via compare(T o1, T o2).

34
New cards

How does the BitSet class store data, and what does the cardinality() method return?

BitSet stores a sequence of bits (11 for true, 00 for false) packed efficiently into words, and cardinality() returns the total number of set bits (true bits).

35
New cards

How are Java assertions enabled when running an application from the command line?

Assertions are disabled by default and must be explicitly enabled using the -ea switch: java -ea

36
New cards

Which classes are used together in Java to support internationalization and localization (L10N)?

Locale (which identifies a specific language and country) and ResourceBundle (which loads localized key-value messages from .properties files).

37
New cards

Why is java.security.SecureRandom used instead of java.util.Random for security-sensitive applications?

java.util.Random uses a Linear Congruential Generator (LCG) algorithm and is not cryptographically secure, whereas SecureRandom provides cryptographically strong pseudorandom generation.

38
New cards

In JavaFX architecture, what is Prism and what rendering paths does it support?

Prism is the graphics rendering engine that handles render jobs using hardware acceleration (Direct3D, OpenGL) or falls back to software rendering if hardware is insufficient.

39
New cards

What are the primary responsibilities of the Glass Windowing Toolkit in JavaFX?

As the lowest level in the graphics stack, it connects JavaFX to native operating system services, manages windows, surfaces, timers, and manages the native event queue.

40
New cards

What is the function of the Quantum Toolkit in the JavaFX architecture?

It coordinates the rendering pipeline (Prism) and the native windowing system (Glass Windowing Toolkit) and enforces JavaFX threading rules.

41
New cards

What are the three main threads running in a standard JavaFX application runtime?

The JavaFX Application Thread (primary thread for UI construction and event handling), the Prism Render Thread (handles rendering separately from event dispatching), and the Media Thread (background synchronization of frames).

42
New cards

What are the three lifecycle methods of a JavaFX Application class, and which one is abstract?

init(), start(Stage primaryStage), and stop(); start(Stage primaryStage) is abstract and must be implemented by the application.

43
New cards

How do Stage and Scene differ in JavaFX?

A Stage represents the top-level operating system window, whereas a Scene represents the container for the visual content inside the stage and hosts the scene graph.

44
New cards

What are the two major phases of event delivery in the JavaFX event-dispatch chain?

The Capturing phase (where the event travels downward from the root node toward the target) and the Bubbling phase (where the event travels upward from the target back toward the root node).

45
New cards
<p>In the provided JavaFX event-dispatch chain diagram, which node is designated as the event target?</p>

In the provided JavaFX event-dispatch chain diagram, which node is designated as the event target?

The Circle node (the leaf node reached through the chain from VBox to HBox).

46
New cards

How do Event Filters and Event Handlers differ in JavaFX event handling?

Event Filters are registered via addEventFilter() and execute during the capturing phase (top-down), while Event Handlers are registered via addEventHandler() or setOnXxx() and execute during the bubbling phase (bottom-up).

47
New cards

What method on an Event object prevents further propagation along the event-dispatch chain?

event.consume();

48
New cards

What are the three core components of the JavaFX Media API and their roles?

Media represents the media resource/file; MediaPlayer controls playback behavior; and MediaView is the Node that renders the visual media within the scene graph.

49
New cards

What underlying engine powers JavaFX web browsing, and how do WebEngine and WebView divide responsibilities?

It is powered by the open-source WebKit engine; WebEngine manages web page loading and browsing logic, while WebView is a Node that renders HTML content in the scene.

50
New cards

At what three stages can user input validation be performed in a JavaFX application?

Validation while entering data (via EventFilter), validation when focus leaves a field (focus-based validation), and validation when the user clicks the submit button.