Which keyword is used to declare an array in Java?
Anonymous Quiz
7%
array
11%
Array
34%
[]
49%
There is no specific keyword; use the data type followed by []
Fix the error in the following Java code snippet to correctly compare two strings for equality.
أصلح الخطأ في الشفرة البرمجية جافا التالية لمقارنة سلسلتين نصيتين بشكل صحيح من أجل المساواة.
String str1 = "Java";
String str2 = "java";
System.out.println(str1 == str2);
أصلح الخطأ في الشفرة البرمجية جافا التالية لمقارنة سلسلتين نصيتين بشكل صحيح من أجل المساواة.
Which method must be implemented by a class that implements the `java.lang.Runnable` interface?
Anonymous Quiz
52%
run()
17%
start()
23%
execute()
8%
perform()
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);
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام العامل الثلاثي؟
Which principle of Object-Oriented Programming allows a subclass to provide a specific implementation of a method that is already provided by one of its superclasses?
Anonymous Quiz
16%
Encapsulation
27%
Polymorphism
49%
Inheritance
8%
Composition
Fix the error in the following Java code snippet to correctly compare two strings for equality.
أصلح الخطأ في الشفرة البرمجية جافا التالية لمقارنة سلسلتين نصيتين بشكل صحيح من أجل المساواة.
String str1 = "Java";
String str2 = "java";
System.out.println(str1 == str2);
أصلح الخطأ في الشفرة البرمجية جافا التالية لمقارنة سلسلتين نصيتين بشكل صحيح من أجل المساواة.
👍3
What is the output of the following code snippet?
int moon = 9, star = 2 + 2 * 3;
float sun = star>10 ? 1 : 3;
double jupiter = (sun + moon) - 1.0f;
int mars = --moon <= 8 ? 2 : 3;
System.out.println(sun+", "+jupiter+", "+mars);
Which collection interface represents a group of objects as a single unit in Java?
Anonymous Quiz
51%
List
8%
Set
11%
Map
31%
Collection
What is the output of the following Java program that demonstrates method overloading?
ما هو مخرج البرنامج جافا التالي الذي يوضح إعادة تحميل الطريقة؟
class DisplayOverloading {
public void disp(char c) {
System.out.println(c);
}
public void disp(char c, int num) {
System.out.println(c + " " + num);
}
}
public class Sample {
public static void main(String[] args) {
DisplayOverloading obj = new DisplayOverloading();
obj.disp('a');
obj.disp('a', 10);
}
}
ما هو مخرج البرنامج جافا التالي الذي يوضح إعادة تحميل الطريقة؟
❤2👍1
What does the `instanceof` keyword check?
Anonymous Quiz
55%
If a variable is an instance of a specific class
14%
If a class is a subclass of another
26%
If a method exists in a class
5%
If a variable is initialized
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;
}
}
جد وصحح الخطأ في الشفرة البرمجية التالية لتنفيذ التغليف بشكل صحيح في جافا.
❤1
What is the correct syntax to declare an interface in Java?
Anonymous Quiz
59%
interface MyInterface {}
17%
class MyInterface {}
7%
Interface MyInterface {}
17%
abstract class MyInterface {}
What will be the output of the following Java code snippet that uses an if-else statement?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة if-else؟
int number = 10;
if(number > 10) {
System.out.println("Number is greater than 10");
} else {
System.out.println("Number is not greater than 10");
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة if-else؟
❤4
How do you initialize an array of integers with the size of 5 in Java?
Anonymous Quiz
30%
int[] array = new int[5];
13%
int array[] = new int[5];
7%
int array[5];
49%
Both A and B are correct
What will be the output of the following Java code snippet that uses an if-else statement?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة if-else؟
int number = 10;
if(number > 10) {
System.out.println("Number is greater than 10");
} else {
System.out.println("Number is not greater than 10");
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة if-else؟
👍1
Which keyword is used to define a class in Java?
Anonymous Quiz
68%
class
17%
Class
6%
obj
9%
object
Consider the following Java code snippet. What will be the output?
فكر في الشفرة البرمجية جافا التالية. ماذا سيكون المخرج؟
class Base {
void display() {
System.out.println("Base display()");
}
}
class Derived extends Base {
void display() {
System.out.println("Derived display()");
}
}
public class Test {
public static void main(String[] args) {
Base obj = new Derived();
obj.display();
}
}
فكر في الشفرة البرمجية جافا التالية. ماذا سيكون المخرج؟
👍2
Which operator is used to compare two values for equality in Java?
Anonymous Quiz
2%
=
90%
==
4%
===
4%
<>
Correct the error in the following Java code snippet that tries to implement multiple interfaces.
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ واجهات متعددة.
interface FirstInterface {
void firstMethod();
}
interface SecondInterface {
void secondMethod();
}
class MyClass implements FirstInterface, SecondInterface {
public void firstMethod() {
// implementation
}
// Missing implementation for secondMethod
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ واجهات متعددة.