Q) What is difference between Executor.submit() and Executer.execute() method ?
There is a difference when looking at exception handling.
If your tasks throws an exception and if it was submitted with execute this
exception
will go to the uncaught exception handler (when you don't have provided one
explicitly,
the default one will just print the stack trace to System.err).
If you submitted the task with submit any thrown exception, checked exception
or not,
is then part of the task's return status. For a task that was submitted with
submit
and that terminates with an exception, the Future.get will re-throw this
exception,
wrapped in an ExecutionException.
Q) What is the difference between factory and abstract factory pattern?
Abstract Factory provides one more level of abstraction.
Consider different factories each extended from an Abstract Factory and
responsible for
creation of different hierarchies of objects based on the type of factory.
E.g. AbstractFactory
extended by AutomobileFactory, UserFactory, RoleFactory etc. Each individual
factory would be
responsible for creation of objects in that genre.