🎉2
public class Test {
public final int value = 4;
public void doIt() {
int value = 6;
Runnable r = new Runnable() {
public final int value = 8;
public void run() {
int value = 10;
System.out.println(this.value);
}
};
r.run();
}
public static void main(String[] args) {
new Test().doIt();
}
}❤2
public class Test {
public static void main(String[] args) {
System.out.println(isEqual(1, 1));
}
private static boolean isEqual(int i, int j) {
return (i == j) ? null : false;
}
}❤1🔥1
🎉1
public class Test {
public static void main(String[] args) {
System.out.println(2 ^ 3);
}
}❤1🔥1
🎉1
public class Test {
public static void main(String[] args) {
int i = 0;
System.out.println(--i++);
}
}❤2🔥1
🌚4🎉1
Какое из утверждений о ключевом слове volatile является полностью корректным?
Anonymous Quiz
17%
volatile делает все операции над переменной атомарными.
54%
volatile гарантирует: изменение переменной будет немедленно видно другим потокам.
4%
volatile полностью заменяет synchronized и имеет те же гарантии.
18%
volatile запрещает CPU и JVM выполнять любые оптимизации вокруг переменной.
8%
volatile гарантирует отсутствие race condition.
🔥2🎉1
public class Test {
public static void main(String[] args) {
System.out.println(true ^ true & false);
}
}💯1
🎉1
class Test {
public static int VAL;
{
VAL = 5;
}
public Test() {
VAL = 10;
}
public static void print() {
System.out.println(VAL);
}
}
public class Quest {
public static void main(String[] args) {
Test.print();
}
}❤2
❤3👍2🎉1
public class Test {
public static void main(String[] args) {
int x = 1;
System.out.println("x+1 = " + x+1);
}
}❤2💯1
❤2🎉2
public class Test {
public static void main(String[] args) {
int i = 0;
method(i);
System.out.print(i);
StringBuilder sb = new StringBuilder();
sb.append("1");
method2(sb);
System.out.print(sb);
}
public static void method(int val) {
val = 1;
}
public static void method2(StringBuilder sb) {
sb.append("2");
sb = new StringBuilder();
sb.append("3");
}
}❤1💯1
❤2🔥1🎉1
public class Test {
public static void main(String[] args) {
System.out.println(cond(1) && cond(2));
}
private static boolean cond(int i) {
try {
return false;
} finally {
System.out.print(i);
}
}
}❤1
🎉2❤1