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
In Java, which keyword is used to inherit from a class?
Anonymous Quiz
82%
extends
9%
implements
4%
super
6%
this
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;
}
}
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تغليف خاصية صف.
What is the result of attempting to compile and run a Java program with a `main` method that does not accept any arguments?
Anonymous Quiz
32%
Compile-time error
26%
Runtime error
21%
The program compiles and runs without issues
21%
The program compiles but does not run
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;
}
}
جد وصحح الخطأ في الشفرة البرمجية التالية لتنفيذ التغليف بشكل صحيح في جافا.
Which of the following is a valid declaration of a method that returns an array of integers in Java?
Anonymous Quiz
62%
public int[] getNumbers() {}
26%
public int getNumbers[]() {}
7%
int[] public getNumbers() {}
4%
getNumbers()[] int public {}
What will be the output of the following Java code snippet that demonstrates static method overriding?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح إعادة تعريف الطريقة الثابتة؟
class Parent {
static void show() {
System.out.println("Parent's show()");
}
}
class Child extends Parent {
static void show() {
System.out.println("Child's show()");
}
}
public class Test {
public static void main(String[] args) {
Parent obj = new Child();
obj.show();
}
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح إعادة تعريف الطريقة الثابتة؟
What does the `final` keyword signify when applied to a variable in Java?
Anonymous Quiz
20%
The variable can be initialized only once.
4%
The value of the variable can change at runtime.
29%
The variable is a constant.
46%
Both A and C are correct.
Correct the error in the following Java code snippet that attempts to override a method in a subclass.
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول إعادة تعريف طريقة في فئة فرعية.
class SuperClass {
protected void display() {
System.out.println("SuperClass display");
}
}
class SubClass extends SuperClass {
private void display() {
System.out.println("SubClass display");
}
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول إعادة تعريف طريقة في فئة فرعية.
https://t.me/java_coffee1
رابط القروب تتناقش فيه مواضيع تقنيه غير الجافا علشان مانطلع من هذا القروب عن الجافا
رابط القروب تتناقش فيه مواضيع تقنيه غير الجافا علشان مانطلع من هذا القروب عن الجافا
👍3❤1🔥1
What keyword is used to access a method or variable from the superclass in a subclass?
Anonymous Quiz
61%
super
14%
this
19%
extends
6%
parent
Identify and fix the error in the following Java code snippet that defines an enum for days of the week.
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تعرف enum لأيام الأسبوع.
enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تعرف enum لأيام الأسبوع.
Which of the following is a valid declaration of a String variable in Java?
Anonymous Quiz
14%
String name = 'John';
10%
string name = "John";
70%
String name = "John";
6%
Str name = 'John';
❤1
What is the output of the following Java code snippet demonstrating the concept of method overriding?
ما هو مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم إعادة تعريف الطريقة؟
class Vehicle {
void run() {
System.out.println("Vehicle is running");
}
}
class Bike extends Vehicle {
void run() {
System.out.println("Bike is running safely");
}
}
public class Test {
public static void main(String[] args) {
Bike obj = new Bike();
obj.run();
}
}
ما هو مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم إعادة تعريف الطريقة؟
What concept in Java is used to hide the internal implementation details of a class and only show the functionality to the user?
Anonymous Quiz
47%
Encapsulation
16%
Inheritance
9%
Polymorphism
27%
Abstraction
What will be the output of the following Java code snippet that demonstrates the use of a static variable?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام متغير ثابت؟
class Counter {
static int count = 0;
Counter() {
count++;
System.out.println(count);
}
}
public class TestStaticVariable {
public static void main(String[] args) {
new Counter();
new Counter();
}
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح استخدام متغير ثابت؟
👍2
What is the correct way to declare a variable to store an integer value in Java?
Anonymous Quiz
97%
int num;
1%
integer num;
0%
num int;
2%
Int num;