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
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ واجهات متعددة.
What is the default value of an object reference declared as an instance variable in Java?
Anonymous Quiz
65%
null
16%
0
7%
undefined
12%
Not assigned
Identify the output of the following Java code snippet that demonstrates the concept of method overloading.
حدد مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم تحميل الطريقة.
class Display {
void show(int a) {
System.out.println("Integer: " + a);
}
void show(String b) {
System.out.println("String: " + b);
}
}
public class Test {
public static void main(String[] args) {
Display obj = new Display();
obj.show(10);
obj.show("Java");
}
}
حدد مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم تحميل الطريقة.
❤2
What is the default value of an int variable declared as an instance variable in a class in Java?
Anonymous Quiz
72%
0
4%
1
19%
null
4%
Not initialized
Correct the following Java code snippet to use the 'final' keyword appropriately.
صحح الشفرة البرمجية جافا التالية لاستخدام كلمة 'final' بشكل مناسب.
class Car {
final int MAX_SPEED;
Car() {
MAX_SPEED = 120;
}
}
صحح الشفرة البرمجية جافا التالية لاستخدام كلمة 'final' بشكل مناسب.
Which of the following is true about static methods in Java?
Anonymous Quiz
56%
They can be called without creating an instance of the class
20%
They can access instance variables directly
5%
They must return a value
19%
They cannot be overloaded
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();
}
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي توضح إعادة تعريف الطريقة الثابتة؟
👍1
Which of the following is the correct way to define a constructor for a class named `Book` in Java?
Anonymous Quiz
46%
public Book() {}
24%
Book() {}
28%
public void Book() {}
1%
void Book() {}
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!");
}
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية لجعلها تترجم بنجاح.
👍1
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