test chivos Flashcards
<p>Metodos siempre del objecto
| Variables siempre de la referencia</p>
<p>si el metodo del objeto llama a una variable en ambas,, se llama a la variable del objeto</p>
, el metodo siempre va sobre el objeto a menos que el metodo sea estatico, en ese caso va sobre la referencia y debe llamarse como a un metodo estatico, HOLA.METODOESTATICO(); si la referencia fuera una interfaz sino no compila
<p>IntSupplier, DoubleSupplier and so on, must return a primitive and not null otherwise</p>
<p>nullpointerException</p>
<p>binarySearch returns?</p>
<p>index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.</p>
<p>In arrayDeque what does the add, push and offer methods do</p>
<p>adds the element to the end while push() is a stack method that adds the element to the front.
offer adds elements to the end but offerFirst adds the element to the front</p>
<p>In ArrayDeque what does de pop and remove methods do</p>
<p>Pop() removes the element from the front
| Remove() removes the element from the front.</p>
<p>Since Queue is a FIFO add to the end and remove from the front structure has the methods¡</p>
<p>offer(e)/add(e) to add to the end
poll()/remove()(for removing an element from the front or head)
add(e) throws an exception if the element cannot be added to the queue because of lack of capacity, while offer(e) does not.</p>
<p>Since Stack is a LIFO add to the front and remove from the front structure has the methods</p>
<p>push(e) and pop() for this purpose, where push adds to the front and pop removes from the front.</p>
<p>pollFirst()/pollLast()?
| removeFirst()/removeLast(</p>
<p>pollFirst and pollLast will remove elements from the front and from the end respectively.
removeFirst()/removeLast remove elements from the front and from the end respectively.
These methods differ from pollFirst/pollLast only in that they throw an exception if this deque is empty.</p>
<p>offerFirst(e)/offerLast(e)
| addFirst(e)/addLast(e)</p>
<p>offerFirst and offerLast will add elements to the front and to the end respectively.
addFirst and addLast will add elements to the front and to the end respectively.</p>
<p>peek(), peekFirst():
peekLast()
element():</p>
<p>peek(), peekFirst(): return the first element from the front of the queue but does not remove it from the queue.
peekLast() : returns the last element from the end of the queue but does not remove it from the queue.
element(): retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from peek only in that it throws an exception if this deque is empty.</p>
<p>Period p = Period.between(LocalDate.now(), LocalDate.of(2015, Month.SEPTEMBER, 1));</p>
<p>Note that if the second date is before the first date, a minus sign is included in the output.</p>
if working with timeZones, try to convert both to global timezone and then do the math or just invert the order
<p>Design pattern</p>
<p>Is a common solutions to software development problem, example, singleton, inmutability, etc</p>
<p>lower and higher,</p>
<p>is strictly lower and the other is lower or equal</p>
<p>CyclicBarrier</p>
<p>allows multiple threads to run independently but wait at one point until all of the coordinating threads arrive at that point.
It is like multiple cyclists taking different routes to reach a particular junction. They may arrive at different times but they will wait there until everyone arrives. Once everyone is there, they can go on futher independent of each other.</p>
<p>Static method on interfaces must be call directly on the interface: like not on the object</p>
<p>Office.callingStaticMethod()</p>
<p>It is easy to identify which operations are intermediate and which are terminal. All intermediate operations return Stream (that means, they can be chained), while terminal operations don't.</p>
<p>filter, peek, and map are intermediate operations. Since the code does not invoke any terminal operation on the stream, the calls to these intermediate method do nothing. Therefore, no output is produced by the given code.
count, forEach, sum, allMatch, noneMatch, anyMatch, findFirst, and findAny are terminal operations.</p>
<p>ResultSetMetaData?</p>
<p>gives you the information about the result of executing a query. You can retrieve this object by calling getMetaData() on ResultSet.
Some important methods are:
getColumnCount(), getColumnName(int col), getColumnLabel(int col), and getColumnType(int col). Remember that the column index starts from 1.</p>
DeadLock
Starvation
LiveLock
Deadlock describes a situation where two or more threads are blocked forever, waiting for each other.
Starvation describes a situation where a thread is unable to gain regular access to shared resources and is unable to make progress.
Livelock: A thread often acts in response to the action of another thread. If the other thread’s action is also a response to the action of another thread, then livelock may result.