Java for Beginner
743 subscribers
708 photos
196 videos
12 files
1.14K links
Канал от новичков для новичков!
Изучайте Java вместе с нами!
Здесь мы обмениваемся опытом и постоянно изучаем что-то новое!

Наш YouTube канал - https://www.youtube.com/@Java_Beginner-Dev

Наш канал на RUTube - https://rutube.ru/channel/37896292/
Download Telegram
Что выведет код?

public class Task080925 {
public static void main(String[] args) {
Long a = 100L;
Long b = 100L;
Long c = 200L;
Long d = 200L;

System.out.println((a == b) + " " + (c == d));
}
}


#Tasks
👍3
Что выведет код?

interface Calculator090925 {
static int multiply(int a, int b) {
return a * b;
}

default int add(int a, int b) {
return a + b;
}
}

class Math090925 implements Calculator090925 {}

public class Task090925 {
public static void main(String[] args) {
Math090925 math = new Math090925();
System.out.println(math.add(2, 3));
System.out.println(Math.multiply(2, 3));
}
}


#Tasks
👍3
Что выведет код?

public class Task100925 {
public static void main(String[] args) {
int[] a = {1, 2, 3};
int[] b = a;
b[0] = 10;
System.out.println(a[0]);
}
}


#Tasks
👍3
Что выведет код?

public class Task110925 {
public static void main(String[] args) {
final int x = 10;
final int y = getValue();

System.out.println(x + y);
}

static int getValue() {
return 20;
}
}


#Tasks
👍3
Что выведет код?

public class Task120925 {
public static void main(String[] args) {
double a = 0.1;
double b = 0.2;
double c = 0.3;

System.out.println(a + b == c);
}
}


#Tasks
👍3
Что выведет код?

public class Task150925 {
static int x = 5;

static {
x = 10;
y = 20;
}

static int y = 15;

public static void main(String[] args) {
System.out.println(x + " " + y);
}
}


#Tasks
🤯2
Что выведет код?

import java.util.concurrent.*;

public class Task160925 {
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<String> future = executor.submit(() -> {
Thread.sleep(1000);
return "Done";
});

System.out.println(future.get(500, TimeUnit.MILLISECONDS));
executor.shutdown();
}
}


#Tasks
👍2
Что выведет код?

enum Status {
ACTIVE, INACTIVE;

Status() {
System.out.print(this.name() + " ");
}
}

public class Task170925 {
public static void main(String[] args) {
System.out.print("Start ");
Status status = Status.ACTIVE;
System.out.print("End");
}
}


#Tasks
🔥2
Что выведет код?

import java.util.HashSet;
import java.util.Set;

public class Task180925 {
public static void main(String[] args) {
Point p1 = new Point(1, 2);
Point p2 = new Point(1, 3);
Set<Point> set = new HashSet<>();
set.add(p1);
set.add(p2);
System.out.println(set.size());
}

public record Point(int x, int y) {
public Point {
if (x < 0) throw new IllegalArgumentException("x < 0");
if (y < 0) throw new IllegalArgumentException("y < 0");
}

public boolean equals(Object o) {
return o instanceof Point p && p.x == x;
}

public int hashCode() {
return x;
}
}
}


#Tasks
👍2
Что выведет код?

class Animal190925 {
public String speak() {
return "Some sound";
}
}

class Dog190925 extends Animal190925 {
public String speak() {
return "Woof";
}

public String fetch() {
return "Fetching stick";
}
}

public class Task190925 {
public static void main(String[] args) {
Animal190925 myAnimal = new Dog190925();
System.out.println(myAnimal.speak());
System.out.println(myAnimal.fetch());
}
}


#Tasks
👍4