...
Fichier Détails
Cartes-fiches | 83 |
---|---|
Langue | English |
Catégorie | Informatique |
Niveau | Autres |
Crée / Actualisé | 02.05.2019 / 03.05.2019 |
Lien de web |
https://card2brain.ch/box/20190502_ocp_before_exam
|
Intégrer |
<iframe src="https://card2brain.ch/box/20190502_ocp_before_exam/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
Créer ou copier des fichiers d'apprentissage
Avec un upgrade tu peux créer ou copier des fichiers d'apprentissage sans limite et utiliser de nombreuses fonctions supplémentaires.
Connecte-toi pour voir toutes les cartes.
What is important when using the ExecutorService class?
It is important to call the shutdown() method. A thread executor creates a non-demon thread on the first task that is executed, so failing to call shutdown will result in you application never terminating.
What is the difference between Runnable and Callable
Callable can return a value and allows a throws declaration of Exception
@FunctionalInterface Callable<V> { V call() throws Exception;}
@FunctionalInterface Runnable { void run()}
What common tools does java offer to prevent race conditions?
- Monitor using the synchronized keyword = Locking
- Atomic clases that provide atomic operations
What is the difference between a BlockingQueue/BlockingDeque and "normal" Queue/Deque?
The Blocking versions offer additional methods that will wait for a specific amount of time to complete an operation:
eg. boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException -> Returns false on timeout
eg. E poll(long timeout, TimeUnit unit) throws InterruptedException -> Returns null on timeout
What is the main difference betwen a serial stream an a parallel stream?
Seria streams are ordered whereas parallel streams are not necessarily
What are the three steps of the fork/join framework?
- Create a ForkJoinTask
- ForkJoinTask<?> task = new MyActionOrTask(...);
- Create the ForkJoinPool
- ForkJoinPool pool = new ForkJoinPool();
- Start the ForkJoinTask
- pool.invoke(action)
- Object result = pool.invoke(task);
Do ExecutorService.submit and ExecutorService.execute throw a checked exception
No
How can you convert an INputStream into a Reader
By wrapping it with a InputStreamReader
What are PrintStream and PrintWriter for?
They write formatted representations of Java objects to a binary stream
Is the int parameter for the InputSTream.mark() method required?
Yes
How can you determine EOF when using a FileReader?
When the readLine() method returns null or or read() returns -1
How can you determine EOF when using a ObjectInputStream?
Catch the EOFException!
is it safe to use inputsream.available() to check if a stream is EOF?
NO! Use the specific strategies for each kind of stream
How is a serialized object created?
- Java calls the first non-arg constructor for the first nonserializable parent class, skipping the constructors of all serialized classes in between!
- Static variables are ignored
- default intializers (eg private String myField = "123" and {}) are ignored
What is special about the print, println, printf and format methods found on the PrintStream/PrintWriter classes?
They do not throw an exception! The checkError() method can be used for that instead
Does DateTimeFormatter throw a Checked Exception or an uncheced?
It throws a DateTimeException which is a RuntimeException
Is it dangerous to ommit the generic type when using Predicate or Function?
Yes:
- Compiler Warning
- Auto Boxing might not work as Expected, eg. boolean will neither be autoboxed into a Boolean nor Object!
Does forEach accept an implementation of Function?
No, only a Consumer implementation!
What happens when catching an checked exception that is not declared by any method in the try block?
The code will not compile!
Can you declare a Method as final?
Yes, instance methods, but not static methods!
Must a ENUM enumeration end with a Semicolon?
The semicolon is only required when methods/constructors are declared afterwards!
What is the difference between Optional.orElse(...) and Optional.orElseGet(...)?
- Optional.orElse(T) returns the provided value
- Optional.orElseGet(Supplier<? extends T>) uses the provided supplier to get the default value
Can a Properties Class be instantiated using a Constructor?
Yes
Is InputStream an Interrface?
No, it's an abstract class!
Is Writer an Interface?
No, its an abstract class
How big is a short?
2 Bytes
When does isSameFile return true?
- when p1.equals(p2) -> true
- when on different FS -> false
- when the same file: true
- including symlinks
- may require to open or access both files
Does instant have a plus method?
Yes, but it only supports units of DAYS or smaller!
Is a Patho object immutable?
Yes! Same as with the new DateTime API
When having an updatable result set and calling a updateXX method, are the changes applied immediately?
No, updateRow must be called before the changes are applied on the DB.
-
- 1 / 83
-