Which of these array declarations is not valid in Java?
Anonymous Quiz
17%
int[] arr = new int[5];
11%
int arr[] = new int[5];
47%
int arr[5];
25%
Both A and B are correct
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");
}
}
صحح الخطأ في الشفرة البرمجية جافا التالية لتوضيح المفهوم المجرد.
What is polymorphism in Java?
Anonymous Quiz
56%
The ability of a variable, function or object to take on multiple forms
20%
The concept of wrapping data and methods into a single unit
12%
The process of moving the common method logic up to a parent class
12%
The capability of Java to run on various operating systems
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());
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية لكي تطبع بشكل صحيح طول المصفوفة.
👍1
Which method is called when an object is created in Java?
Anonymous Quiz
10%
init()
31%
main()
7%
start()
51%
constructor
What will be the output of the following Java code snippet that uses a while loop?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم حلقة while؟
int x = 0;
while(x < 5) {
System.out.print(x + " ");
x++;
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم حلقة while؟
❤1
What is the correct way to declare a variable of type double in Java?
Anonymous Quiz
89%
double num = 10.5;
6%
Double num = 10.5;
4%
double num = '10.5';
1%
double num = "10.5";
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 syntax to declare a class named 'Vehicle' in Java?
Anonymous Quiz
24%
class Vehicle {}
4%
Class Vehicle {}
41%
public class Vehicle {}
31%
All of the above are correct
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();
}
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام الصفوف المجردة؟
❤1
Which collection class in Java ensures that elements are sorted?
Anonymous Quiz
61%
ArrayList
12%
HashSet
18%
TreeSet
9%
LinkedList
❤1🤩1
What does the `break` statement do in a loop in Java?
Anonymous Quiz
14%
Pauses the loop
17%
Continues to the next iteration of the loop
67%
Exits the loop immediately
1%
Decreases the loop counter by one
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);
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام العامل الثلاثي؟
Fix the error in the following Java code snippet to correctly iterate over an array using a for loop.
أصلح الخطأ في الشفرة البرمجية جافا التالية لتكرار على مصفوفة باستخدام حلقة for بشكل صحيح.
int[] arr = {1, 2, 3, 4, 5};
for(int i = 0; i <= arr.length; i++) {
System.out.println(arr[i]);
}
أصلح الخطأ في الشفرة البرمجية جافا التالية لتكرار على مصفوفة باستخدام حلقة for بشكل صحيح.
What is the output of the following code snippet?
```java
int a = 5; int b = 2; System.out.println(a / b); ```
```java
int a = 5; int b = 2; System.out.println(a / b); ```
Anonymous Quiz
27%
2.5
62%
2
2%
3
9%
None of the above
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");
}
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ طريقة مجردة في واجهة.
❤1👍1
Which of the following is not a loop construct in Java?
Anonymous Quiz
8%
for
3%
while
6%
do-while
83%
repeat-until
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);
}
أصلح الخطأ في الشفرة البرمجية جافا التالية لحساب عامل رقم باستخدام العودية بشكل صحيح.
❤1