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?

A

Throwable

24
Q

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

A

Exception

25
Q

What kind of programs are GUIs?

A

Event-Driven Programs

26
Q

What is meant by “heavyweight” when referirng to GUI?

A

Depend heavily on OS

27
Q

What did Swing improve upon from the original Java AWT GUI components?

A

Lightweight (less OS involvement), more powerful

28
Q

What is AWT?

A

Abstract Windows Toolkit

29
Q

What is a container object?

A

An object to hold other GUI components

30
Q

What are 3 examples of container objects?

A

1) Window
2) Frame
3) Panel

31
Q

How do you set a JFrame’s position in the middle?

A

setLocationRelativeTo(null);

32
Q

Which container comes with a title?

A

JFrame

33
Q

What should be the final method in your boilerplate code?

A

setVisible(true)

34
Q

What is the most common layout manager?

A

FlowLayout

35
Q

What is the default layout manager for JFrame?

A

BorderLayout

36
Q

What is the Event Delegation Model?

A

The responsibility for handling events is given to an object other than the one that produced the event

37
Q

What is an event?

A

An object created when a user interacts with something, like a button in a GUI

38
Q

What kind of event does a JButton create?

A

ActionEvent

39
Q

What is the mother of all classes in JavaFX?

A

Application Class

40
Q

What is the top level container class in JavaFX?

A

Stage Class

41
Q

Which class in JavaFX is analogous to a JFrame in Swing?

A

Stage class

42
Q

Which sub-container typically gets added to a stage container?

A

Scene

43
Q

What method provides the Stage object?

A

launch()

44
Q

What code is needed in main to start a GUI in JavaFX?

A

launch()

45
Q

What are individual elements like TextFields and Buttons called in JavaFX?

A

Nodes

46
Q

What is a node without a child called?

A

Terminal node (or leaves)

47
Q

What is a scene graph?

A

The collection of all the nodes

48
Q

What is a root node?

A

The top-level node

49
Q

What are the 3 life-cycle methods provided by the application class?

A
  1. init()
  2. start()
  3. stop()
50
Q

What method is analogous to the JFrame constructor method in JavaFx?

A

start(Stage primaryStage)

51
Q

What are the two types of MouseEvent listeners?

A
  1. MouseListener

2. MouseMotionListener

52
Q

What are 3 different kinds of event objects?

A

ActionEvent, ChangeEvent, ItemEvent