DEVFYI - Developer Resource - FYI

There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

Java Interview Questions and Answers (part 3)


(Continued from previous question...)

459. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

If these classes are threads I'd consider notify() or notifyAll(). For regular classes you can use the Observer interface.

(Continued on next question...)

Other Interview Questions