Ideally, you should have one mainstream programming language down very well, to use in interviews. Java is mine.
interrupt() on the Thread object for the thread to be interrupted. For the interrupt mechanism to work correctly, the interrupted thread must support its own interruption.join method allows one thread to wait for the completion of another. If it is a Thread object that is currently executing, then thread.join(); causes the current thread to pause execution until its thread terminates.main of some designated class). The JVM continues to execute threads until either of the following occurs:
Runtime has been called and the security manager has permitted the exit operation to take place.thread.setDaemon(true); wasn’t called) have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.| Type | bits | Bytes |
|---|---|---|
| boolean | 1 bit | 1 Byte |
| byte | 8 bit | 1 Byte |
| short | 16 bit | 2 Byte |
| char | 16 bit | 2 Byte |
| int | 32 bit | 4 Byte |
| float | 32 bit | 4 Byte |
| long | 64 bit | 8 Byte |
| double | 64 bit | 8 Byte |
BitSet – a bit vector with growing size, each element is a boolean with 1-bit size (not 8-bit as regular booleans).

java.lang.OutOfMemoryError: PermGen).MaxMetaspaceSize the Metaspace will dynamically resize depending on the application demand at runtime.MaxMetaspaceSize option.finalize() method of the object, allowing for cleanup operations (but don’t use finalizers – Effective Java 2nd Ed. Item 7).Runtime.gc() or System.gc()) but it’s not guaranteed to happen.OutOfMemoryError exception is thrown.WeakHashMap.ThreadLocal, see linkmyString.intern() – places string in memory pool that can’t be removedHashSet/Map which uses incorrect hashCode, so elements are always added-Xms1g – Initial heap size-Xmx2g – Hax heap size-XX:MaxMetaspaceSize=200m – Add a limit to Metaspace (not limited by default)-Xmn500m – Initial and max young gen size-XX:SurvivorRatio=4 – Ratio of survivor size relatively to eden size (ratio = young/survivor - 2)-Xss256k – Thread frame stack sizejava.util.BitSet to work with single bits.int a = 0b101;
assertEquals(5, a); // true
int zero = 0b0;
int one = 0b1;
int two = 0b10;
int three = 0b11;
int five = 0b101;
x) in two’s complement:
~x)1 bit (x + 1)int x = 4;
int minusX = ~x + 1;
assertEquals(-4, minusX); // true
int minusOne = 0b11111111111111111111111111111111;
int minusTwo = 0b11111111111111111111111111111110;
int minusThree = 0b11111111111111111111111111111101;
int minusFour = 0b11111111111111111111111111111100;
int minusFive = 0b11111111111111111111111111111011;
>>
>>>
0, irrespective of the sign of the number.int casting drops any decimal, essentially rounding down.toCharArray().final.+ operator translates to StringBuilder operations by the compiler, but creates a new instance of StringBuilder for every concatenation. Use StringBuilder directly for repeated concatenation in multiple statements with intermediate strings (single statements are fine, e.g., for String s = a + b + c use StringBuilder).String s = "hello", are interned by the compiler.String.public String intern() function on String places that instance in the pool and returns the canonical representation for that string object.intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned.String object is added to the pool and a reference to this String object is returned.== tests for reference equality (whether they are the same object)..equals() tests for value equality (whether they are logically equal).new String("test") == "test" is falsenew String("test") == new String("test") is false"test" == "test" is true.equals(). In the rare situation where you know you’re dealing with interned strings, you can use ==.wait(), notify(), and notifyAll() methods.Object, so all classes have them.synchronized method.wait() tells the calling thread to give up the monitor and go to sleep until some other thread enters the same monitor and calls notify().wait() exist that allow you to specify a period of time to wait.notify() wakes up the first thread that called wait() on the same object.notifyAll() wakes up all the threads that called wait() on the same object. The highest priority thread will run first.wait/notify directly and use the Lock class and others from java.util.concurrent.locks instead.| Modifier | Class | Package | Subclass | World |
|---|---|---|---|---|
public |
Yes | Yes | Yes | Yes |
protected |
Yes | Yes | Yes | No |
| no modifier | Yes | Yes | No | No |
private |
Yes | No | No | No |
int to an Integer).valueOf to autobox and intValue to unbox (for int, for example).+ for example), so using it on Integer will trigger unboxing and then autoboxing.== don’t unbox and so reference are compares, not values. So to compare two Integers use .equals() or preferrable use primitive types.NullPointerExceptions when unboxing.