ch
Feedback
جافا Java

جافا Java

前往频道在 Telegram

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

显示更多
6 325
订阅者
-324 小时
-127
-6030
帖子存档
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؟

Which method is called when an object is created in Java?
Anonymous voting

Identify and fix the error in the following Java code snippet so it correctly prints the length of the array.
int[] numbers = new int[5];
System.out.println(numbers.length());
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية لكي تطبع بشكل صحيح طول المصفوفة.

What is polymorphism in Java?
Anonymous voting

Correct the error in the following Java code snippet to demonstrate abstraction.
abstract clas Vehicle {
    abstract void start();
}
class Car extends Vehicle {
    void start() {
        System.out.println("Car starts with a key");
    }
}
صحح الخطأ في الشفرة البرمجية جافا التالية لتوضيح المفهوم المجرد.

Which of these array declarations is not valid in Java?
Anonymous voting

Identify and fix the error in the following Java code snippet to make it compile successfully.
public clas HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية لجعلها تترجم بنجاح.