es
Feedback
جافا Java

جافا Java

Ir al canal en Telegram

ليس عيبًا ألا تعرف شيئًا، ولكن العيب انك لا تريد أن تتعلم

Mostrar más
6 166
Suscriptores
-324 horas
-147 días
-6930 días
Archivo de publicaciones
Find and correct the error in the following code snippet to correctly implement encapsulation in Java.
class Student {
    private int age;
    public void setAge(int age) {
        if(age > 0) {
            this.age = age;
        }
    }
    public int getAge() {
        return age;
    }
}
جد وصحح الخطأ في الشفرة البرمجية التالية لتنفيذ التغليف بشكل صحيح في جافا.

What is the result of attempting to compile and run a Java program with a `main` method that does not accept any arguments?
Anonymous voting

Correct the error in the following Java code snippet that tries to encapsulate a class property.
class Student {
    private int age;
    public getAge() {
        return age;
    }
    public void setAge(int age) {
        if(age > 0) {
            this.age = age;
        }
    }
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تغليف خاصية صف.

In Java, which keyword is used to inherit from a class?
Anonymous voting

Fix the error in the following Java code snippet to correctly calculate the factorial of a number using recursion.
public int factorial(int n) {
    if (n == 1)
        return 1;
    else
        return n * factorial(n - 1);
}
أصلح الخطأ في الشفرة البرمجية جافا التالية لحساب عامل رقم باستخدام العودية بشكل صحيح.

Which of the following is not a loop construct in Java?
Anonymous voting

Identify and fix the error in the following Java code snippet that tries to implement an abstract method in an interface.
interface Animal {
    abstract void eat();
}
class Dog implements Animal {
    public void eat() {
        System.out.println("Dog eats");
    }
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ طريقة مجردة في واجهة.

What is the output of the following code snippet? ```java int a = 5; int b = 2; System.out.println(a / b); ```
Anonymous voting

Fix the error in the following Java code snippet to correctly iterate over an array using a for loop.
int[] arr = {1, 2, 3, 4, 5};
for(int i = 0; i <= arr.length; i++) {
    System.out.println(arr[i]);
}
أصلح الخطأ في الشفرة البرمجية جافا التالية لتكرار على مصفوفة باستخدام حلقة for بشكل صحيح.

In Java, which operator is used for logical AND operation?
Anonymous voting

What will be the output of the following Java code snippet that demonstrates the use of the ternary operator?
int a = 10, b = 5;
int result = (a > b) ? a : b;
System.out.println(result);
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام العامل الثلاثي؟

What does the `break` statement do in a loop in Java?
Anonymous voting

What is the output of the following Java code snippet that demonstrates the concept of inheritance and method overriding?
class Animal {
    String shout() { return "Don't know!"; }
}
class Dog extends Animal {
    String shout() { return "Woof!"; }
}
public class TestAnimal {
    public static void main(String[] args) {
        Animal myAnimal = new Dog();
        System.out.println(myAnimal.shout());
    }
}
ما هو مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم الوراثة وإعادة تعريف الطريقة؟

Which collection class in Java ensures that elements are sorted?
Anonymous voting

اختر الإجابة الخاطئة لتعريف الدوال في جافا
اختر الإجابة الخاطئة لتعريف الدوال في جافا

What will be the output of the following Java code snippet demonstrating the use of abstract classes?
abstract class Shape {
    abstract void draw();
}
class Rectangle extends Shape {
    void draw() {
        System.out.println("Drawing Rectangle");
    }
}
public class Test {
    public static void main(String[] args) {
        Shape shape = new Rectangle();
        shape.draw();
    }
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام الصفوف المجردة؟

What is the correct syntax to declare a class named 'Vehicle' in Java?
Anonymous voting

What will be the output of the following Java code snippet that demonstrates the use of static variables?
class Counter {
    static int count = 0;
    Counter() {
        count++;
        System.out.println(count);
    }
}
public class TestCounter {
    public static void main(String[] args) {
        Counter c1 = new Counter();
        Counter c2 = new Counter();
        Counter c3 = new Counter();
    }
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام المتغيرات الثابتة؟

What is the correct way to declare a variable of type double in Java?
Anonymous voting

What will be the output of the following Java code snippet that uses a while loop?
int x = 0;
while(x < 5) {
    System.out.print(x + " ");
    x++;
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم حلقة while؟