EXAM Flashcards

1
Q

An interface is a class that includes:

A

Abstract public methods and constant values

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

Interfaces hold values by default how?

A

Public, static, final

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

What are the two main uses of interfaces in Java?

A

1) Implementing a common function throughout many classes

2) Simulate multiple inheritance

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

What keyword is used when a class uses an interface?

A

implements

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

If a method has a code block in an interface, what keyword is used?

A

default

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

Do you have to override a default method from an interface?

A

No

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

What kind of inheritance does Java use?

A

Single inheritance

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

Can you instantiate an object of an interface class?

A

No

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

What is a functional interface?

A

An interface with only one abstract method

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

What is an exception?

A

An object that signals an error

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

What is a major benefit of using exceptions for errors?

A

Separates the code for errors from the code while running smoothly

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

Why should exceptions only be used for unusual or catastrophic events?

A

Exceptions involve a lot of overhead, potentially reducing performance dramatically.

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

What does a catch block use as a parameter?

A

An exception object

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

What are the 4 categories of exceptions?

A

1) Code or Data Errors
2) Standard Method Exceptions
3) Throwing your own exceptions
4) Java errors

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

What are all exceptions a subclass of?

A

Throwable

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

What are the 2 subclasses of Throwable?

A

1) Error

2) Exception

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

Unchecked exceptions are from which class?

A

The Runtime Class (Error class too)

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

What are some common runtime exceptions?

A

ArithmeticException, IndexOutOfBounds, NullPointer

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

What are the 2 ways to deal with checked exceptions?

A

1) Confess using “throws” keyword in header

2) try-catch blocks

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

What block of code is always executed regardless of exceptions?

A

finally block

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

What is important to remember when writing multiple catch blocks?

A

Order matters. The most abstract (least specific) should be at the bottom.

22
Q

What are 3 useful methods held in Throwable class?

A

getMessage()
printStackTrace()
printStackTrace(printStream e)

23
Q

When defining your own exception class, what class must be a superclass?

24
Q

What is the best class to extend your own exception classes from?

25
What kind of programs are GUIs?
Event-Driven Programs
26
What is meant by "heavyweight" when referirng to GUI?
Depend heavily on OS
27
What did Swing improve upon from the original Java AWT GUI components?
Lightweight (less OS involvement), more powerful
28
What is AWT?
Abstract Windows Toolkit
29
What is a container object?
An object to hold other GUI components
30
What are 3 examples of container objects?
1) Window 2) Frame 3) Panel
31
How do you set a JFrame's position in the middle?
setLocationRelativeTo(null);
32
Which container comes with a title?
JFrame
33
What should be the final method in your boilerplate code?
setVisible(true)
34
What is the most common layout manager?
FlowLayout
35
What is the default layout manager for JFrame?
BorderLayout
36
What is the Event Delegation Model?
The responsibility for handling events is given to an object other than the one that produced the event
37
What is an event?
An object created when a user interacts with something, like a button in a GUI
38
What kind of event does a JButton create?
ActionEvent
39
What is the mother of all classes in JavaFX?
Application Class
40
What is the top level container class in JavaFX?
Stage Class
41
Which class in JavaFX is analogous to a JFrame in Swing?
Stage class
42
Which sub-container typically gets added to a stage container?
Scene
43
What method provides the Stage object?
launch()
44
What code is needed in main to start a GUI in JavaFX?
launch()
45
What are individual elements like TextFields and Buttons called in JavaFX?
Nodes
46
What is a node without a child called?
Terminal node (or leaves)
47
What is a scene graph?
The collection of all the nodes
48
What is a root node?
The top-level node
49
What are the 3 life-cycle methods provided by the application class?
1. init() 2. start() 3. stop()
50
What method is analogous to the JFrame constructor method in JavaFx?
start(Stage primaryStage)
51
What are the two types of MouseEvent listeners?
1. MouseListener | 2. MouseMotionListener
52
What are 3 different kinds of event objects?
ActionEvent, ChangeEvent, ItemEvent