🎉2
public class Test {
public static void main(String[] args) {
System.out.println("5" + true);
}
}❤2
❤2👎1🎉1
public class Test {
public static void main(String[] args) {
boolean f = false;
System.out.println(f = f ^ true);
}
}❤3
✍1🎉1
class Person {
public static int idGenerator = 0;
private int id;
public Person() {
this.id = idGenerator++;
}
}
public class Test {
public static void main(String[] args) {
Person[] arr = new Person[10];
System.out.println(Person.idGenerator);
}
}❤2
🎉2❤1
public class Test {
public static void main(String[] args) {
System.out.println(true &! false);
}
}❤1
🤡3❤2👍2🎉1💯1
public class Test {
public static void main(String[] args) {
boolean b = false;
System.out.println(b++);
}
}❤1
❤2🎉1
class One {
public static void go() {
System.out.print("one ");
}
}
class Two extends One {
public static void go() {
System.out.print("two ");
}
}
class Three extends Two {
public static void go() {
System.out.print("three ");
}
}
public class Test {
public static void main(String[] args) {
One one = new One();
one.go();
One two = new Two();
two.go();
Two two2 = new Three();
two2.go();
}
}❤2
Что выведет код? 👆
Anonymous Quiz
47%
one two three
35%
one one two
14%
one one one
4%
<Ошибка компиляции>
❤3
public class Test {
public static void main(String[] args) {
System.out.println(condition(null) ? 1 : 2);
}
public static boolean condition(Number o) {
return true;
}
public static boolean condition(Long l) {
return false;
}
}❤1
❤1🎉1
public class Test {
{
System.out.println(i);
}
int i;
public Test(int i){
this.i = i;
}
public static void main(String[] args) {
new Test(1);
}
}❤1
❤2🎉1
class Dog {
public static void bark() {
System.out.print("Woof ");
}
}
class Basenji extends Dog {
public static void bark() { }
}
public class Bark {
public static void main(String[] args) {
Dog woofer = new Dog();
Dog nipper = new Basenji();
woofer.bark();
nipper.bark();
}
}❤1
🔥1🎉1
class A {
static class B {
static String C = "NOT TO BE";
}
static Z B = new Z();
}
class Z {
String C = "TO BE";
}
public class Test {
public static void main(String[] args) {
System.out.println(A.B.C);
}
}❤1