Java Qarışıq Kuiz

Java qarışıq suallardan ibarət kuiz. Uğurlar!

2 Sentyabr 2024 - 00:17
 0  162

1. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        String str = "Java";
        str = str.concat(" Azərbaycan");
        System.out.println(str);
    }
}

Java
JavaAzərbaycan
Azərbaycan
Java Azərbaycan

2. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        int x = 10;
        int y = ++x * 10 / x++ + ++x;
        System.out.println(y);
    }
}

12
13
23
26

3. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        String str = null;
        try {
            System.out.println(str.length());
        } catch (NullPointerException e) {
            System.out.println("NullPointerException xətası");
        }
    }
}

Compiletime xətası
Runtime xətası
0
NullPointerException xətası

4. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        int[][] arr = {
            {1, 2, 3},
            {4, 5, 6},
            {7, 8, 9}
        };
        System.out.println(arr[1][2]);
    }
}

5
6
7
8

5. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        try {
            int result = 10 / 0;
            System.out.println(result);
        } catch (ArithmeticException e) {
            System.out.println("ArithmeticException xətası");
        } finally {
            System.out.println("Finally blok");
        }
    }
}

ArithmeticException xətası Finally blok
ArithmeticException xətası
Finally blok
Compiletime xətası

6. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder("Java");
        sb.append(" Azərbaycan");
        sb.insert(5, "Kuiz ");
        System.out.println(sb);
    }
}

Java Azərbacan Kuiz
Java Kuiz Azərbaycan
Java Azərbaycan
JavaKuiz

7. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        String str = "Hello";
        str.replace('l', 'p');
        System.out.println(str);
    }
}

Heppo
Hello
Heplo
Helpo

8. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        int sum = 0;
        for (int num : arr) {
            if (num % 2 == 0) {
                continue;
            }
            sum += num;
        }
        System.out.println(sum);
    }
}

15
9
8
10

9. Aşağıdakı kodun çıxışı nə olacaq?

class Parent {
    public void display() {
        System.out.println("Parent Display");
    }
}

class Child extends Parent {
    public void display() {
        System.out.println("Child Display");
    }
}

public class Test {
    public static void main(String[] args) {
        Parent obj = new Child();
        obj.display();
    }
}

Parent Display
Child Display
Parent Display Child Display
Runtime xətası

10. Aşağıdakı kodun çıxışı nə olacaq?

public class Test {
    public static void main(String[] args) {
        int i = 1;
        while (i <= 5) {
            if (i == 3) {
                break;
            }
            System.out.println(i);
            i++;
        }
    }
}

1 2 3
1 2 3 4 5
1 2
1 2 3 4