JavaBeans Flashcards

1
Q

What is component software?

A

Component software is software that is designed to work as a component of a larger application. Think of the way PCs are built: memory chips, CPUs, keyboards, etc.

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

Why does component software work?

A

The interfaces between software components are standardized, so they work together seamlessly.

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

How do components communicate with one another?

A

Through interfaces. The component offers services to the rest of the system. a provided interface specifies the services that other components can utilize, and how they can do so.

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

Are components encapsulated? Why?

A

Yes. Other components do not need to know how the services are implemented, they just need to work.

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

Describe the principle of substitutability with respect to component software.

A

A component should be able to replace another component if the successor component meets the requirements of the initial component (expressed via interfaces). This allows us to use updated versions or an alternative without breaking the system.

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

Name two techniques for employing a component across network links

A
  1. serialization

2. marshalling

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

Compare and contrast object oriented programming and component-based software engineering.

A

OOP believes software should be modeled after the conceptual way we think about objects in the world and how they behave (mammal, dog, barks, etc).

Component-based software states that developers should construct software by gluing together prefabricated components– modularizing systems.

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

Where is a discussion about component programming more relevant, java beans or enterprise java bean? Why?

A

Enterprise Java Bean (EJB). EJBs are distributed components. JavaBeans are local program components, usually GUI.

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

What is the point of a JavaBean?

A

The primary intent of the JaveBean is to support visual application development environments (though the patterns defined by the javabean spec are applicable to class libraries in general).

By default, many java classes are beans simply because they follow javabean method-naming and event-handling conventions.

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

What is a javabean usually?

A

A javabean is usually simply a class that subclasses java.awt.Component and implements object serialization eo externalization.

the javabean follows a standard set of method-naming conventions that allow application builder tools to automatically detect the properties, actions, and events support by a javabean through introspection.

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

What is the purpose of an Enterprise Java Bean?

A

The purpose of an EJB is to isolate business logic and data access in server-side components.

They can also be accessed in visual development tools to link events (perhaps originating from a client javabean).

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

JavaBean can be read as a synonym for what?

A

component

also, it’s pretty much just a java object. :/

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

Where do javabeans typically run, client side or server side?

A

usually client.

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

Enterprise java bean is typically for client or server side?

A

server side

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

Which kind of classes is a javabeans component?

A

every java user interface class is a javabeans component

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

what will learning javabeans help you do?

A

create custom events

develop your own source components that can fire events

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

What are the minimum java bean requirements?

A
  1. A bean must be a public class
  2. A bean must have a no-arg constructor (though it can have others too)
  3. A bean must implement the java.io.Serializable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

A javabean component is a special kind of java class. Sum it up in a sentence.

A

A javabean component is a serializable public class with a public no-arg constructor.

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

Describe property naming patterns for javabeans

A

The javabean, like all classes, can have properties. Primitive type or an object type. The property type dictates the signature of the accessor and mutator methods.

public String getMessage()

public boolean isCentered()

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

what do properties describe in the bean?

A

properties describe the state of the bean

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

data fields are used to store properties. how do they work in beans?

A

a bean property is not necessarily a data field.

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

what is the difference between a property and a field?

A

a property is a concept, a field is an implementation

Field: a data member of a class. unless specified otherwise, a field is not static.

Property: characteristics of an object that users can set, such as the color of a window.

A property may be read-only with a get method but not set method, or write-only with a set method but no get method

23
Q

Can beans communicate with other beans?

A

Yes.

24
Q

What model provides the foundation for communcation between beans?

A

The Java event delegation model enables beans to send, recieve, and handle events.

event object
source object
event listener object

–review event driven programming for more

This is called the “delegation model” because the source object delegates the event to the listeners for processing.

25
Q

What is an event source?

A

The component on which an event is generated.

Every java GUI component is an event source for one or more events.

A JButton object fires a java.awt.event.ActionEvent when it is clicked.

26
Q

what should a source component contain?

A

code that detects and external or internal action that triggers the event

the source should fire an event to the listeners by invoking the event handler defined by the listeners.

the source component must also contain methods for registered and deregistering listeners.

27
Q

what should a listener component do?

A

a listener component for an event must implement the event listener interface.

otherwise, the object of the listener component cannot receive event notifications from a source component.

28
Q

can a listener component have more than one listener interface?

A

yes. it may register many listeners. it may also register itself.

29
Q

what is the naming pattern for removing custom source component?

A

public void removeListener(Listener 1)

30
Q

what is the naming pattern for adding a unicast listener

A

public void addListener(Listener 1)

throws TooManyListenersException;

31
Q

what is the naming pattern for adding a multicast listener

A

public void addListener(Listener 1)

*no exception thrown, as in unicast listener

32
Q

Give an example of a custom source component

A

Course class, when number of students cap has been reached and we need to do something if the cap is exceeded.

33
Q

why does synchronizing certain methods help?

A

avoids data corruption (for example, when attempting to register multiple listeners concurrently)

34
Q

if you want to create a custom event class, what must you extend?

A

java.util.EventObject or a subclass that class

35
Q

a custom event listener interface must extend what class??

A

java.util.EventListener or a subinterface of that class

36
Q

by convention, a custom listener interface should be named what?

A

XListener for the event class named XEvent

37
Q

by convention, a custom event class should be named what?

A

XEvent

38
Q

why doesn’t a custom event class have a no arg constructor?

A

you must always specify a source for the event when creating an event

39
Q

what does unicasted mean?

A

only one listener object is notified of the event

40
Q

what does multicasted mean?

A

each object in a list of listeners is notified of the event

41
Q

what happens when a builder tool inspects a bean that includes:

public color getColor()
public void setColor(Color c)

A
  • the tool infers that a property named color exists
  • the builder tool knows this property is readable and writable
  • the builder knows that the type is Color
  • the builder can look for a property editor for the type, and display the property (usually in a property sheet) for editing
42
Q

what is an indexed property?

A

an indexed property is an ordered collection of values associated with a single name.

The individual values are accessed using an integer index (like an array).

43
Q

What design pattern must an indexed property follow?

A

Access entire array:

public [] get();

public void set()[] value);

Access individual values in the property array:

public [] get(int index);

public void set(int index, )[] value);

44
Q

what is a bound property?

A

a bound property notifies listeners when its value changes.

45
Q

What class must a bound property use?

A

PropertyChangeSupport

46
Q

What methods should a bounded property use?

A

addPropertyChangeListener

removePropertyChangeListener

47
Q

where does PropertyChangeSupport live?

A

java.beans package

48
Q

give an example of how you would use a bound property

A

number of tickets sold at a concert. we only have 1000 tickets. we can’t sell 1001, so we need to close sales when we hit 1000.

49
Q

describe what a bound property must do on a listener list

A

a bound property must be able to add and remove itself

50
Q

what is a constrained property

A

a constrained property is a special kind of bound property

the bean keeps track of a set of veto listeners

when a constrained property is about to change, the listeners are consulted. any one of the listeners has a chance to veto the change.

51
Q

what is a veto listener

A

a veto listener vetos a constrained property change when the property change asks the other listeners if it should change

52
Q

are veto listeners part of the property change listeners?

A

no. they are in the class VetoableChangeSupport

53
Q

where does a veto change live?

A

VetoableChangeSupport