❤2🎉1
Что имеет более высокий уровень абстрации?
Anonymous Quiz
6%
класс
31%
абстрактный класс
63%
интерфейс
❤3👍2🎉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);
}
}👍2
🎉2👍1
public class Test {
public static void main(String[] args) {
System.out.print(condition1() && condition2());
}
private static boolean condition1() {
System.out.print(1);
return false;
}
private static boolean condition2() {
System.out.print(2);
return true;
}
}👍2
🎉1👌1
public class Test {
public static void main(String[] args) {
int i=0;
label1: System.out.print(i++);
if (i < 2) {
goto label1;
}
}
}🙉6😁3❤1🗿1
🎉1
import java.util.HashSet;
import java.util.Set;
public class Test {
public static void main(String[] args) {
String str1 = "Hello World";
String str2 = new String("Hello World");
Set<String> set = new HashSet<>();
set.add(str1);
set.add(str2);
for (String str : set) {
if (str == str1) {
System.out.print("origin ");
}
if (str == str2) {
System.out.print("replace ");
}
}
}
}
❤1
👍4🎉1
public class Test {
public static void main(String[] args) {
System.out.println(10 + 20 + "30");
}
}👏6🎉2
public class Test {
public static void main(String[] args) {
int i = 5;
boolean b = pri(i++ * 2) && pri(i);
}
public static boolean pri(int i) {
System.out.print(i);
return true;
}
}❤2
public class Test {
public static void main(String[] args) {
int b = oper2() | oper3() & oper4();
System.out.println("-" + b);
}
private static byte oper2() {
System.out.print(2);
return 2;
}
private static byte oper3() {
System.out.print(3);
return 3;
}
private static byte oper4() {
System.out.print(4);
return 4;
}
}❤3
🎉4
import java.util.ArrayList;
import java.util.List;
class Person {
Long id;
String name;
public Person(Long id, String name) {
this.id = id;
this.name = name;
}
@Override
public boolean equals(Object obj) {
System.out.print(1);
if (obj == this) {
return true;
}
if (obj instanceof Person person) {
return id.equals(person.id);
}
return false;
}
}
public class Test {
public static void main(String[] args) {
List<Person> list = new ArrayList<>();
list.add(new Person(1L, "Leo"));
list.add(new Person(2L, "Raph"));
list.add(new Person(3L, "Donnie"));
list.add(new Person(4L, "Mikey"));
list.contains(new Person(3L, "Shredder"));
}
}
👍1
🎉2
public class Test {
public static void main(String[] args) {
byte b = 50;
print(b);
}
private static void print(Short num) {
System.out.println(num++);
}
}❤2🔥2
🎉5❤1