In Java, which keyword is used to inherit properties and methods from another class?
Anonymous Quiz
76%
extends
9%
implements
9%
inherits
6%
super
What will be the output of the following Java program that demonstrates the concept of inheritance?
ماذا سيكون المخرج للبرنامج جافا التالي الذي يوضح مفهوم الوراثة؟
class Animal {
String sound() { return "Some sound"; }
}
class Dog extends Animal {
String sound() { return "Bark"; }
}
public class TestInheritance {
public static void main(String[] args) {
Animal myDog = new Dog();
System.out.println(myDog.sound());
}
}
ماذا سيكون المخرج للبرنامج جافا التالي الذي يوضح مفهوم الوراثة؟
How do you declare a method that does not return any value?
Anonymous Quiz
71%
void methodName() {}
15%
public methodName() {}
3%
methodType methodName() {}
11%
None of the above
👍1
Correct the error in the following Java code snippet that defines a method to calculate the sum of two integers.
صحح الخطأ في الشفرة البرمجية جافا التالية التي تعرف طريقة لحساب مجموع عددين صحيحين.
public int sum(int a, int b) {
return a + b
}
صحح الخطأ في الشفرة البرمجية جافا التالية التي تعرف طريقة لحساب مجموع عددين صحيحين.
What keyword is used to import a package in Java?
Anonymous Quiz
27%
package
63%
import
8%
include
2%
use
❤1
Fix the error in the following code snippet that defines a class and tries to create an object of it.
صحح الخطأ في الشفرة البرمجية التالية التي تعرف صفا وتحاول إنشاء كائن منه.
public class Bike {
int speedLimit = 90;
}
public class TestBike {
public static void main(String[] args) {
Bike myBike = new Bike();
System.out.println(myBike.speedLimit);
}
}
صحح الخطأ في الشفرة البرمجية التالية التي تعرف صفا وتحاول إنشاء كائن منه.
❤1
Which statement correctly creates a two-dimensional array in Java?
Anonymous Quiz
80%
int[][] arr = new int[5][5];
10%
int arr[][] = new int[5][];
10%
int[] arr = new int[5][5];
0%
int arr[][] = new int[][5];
What will be the output of the following Java code snippet that uses a switch-case statement?
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة switch-case؟
char grade = 'A';
switch(grade) {
case 'A':
System.out.println("Excellent");
break;
case 'B':
System.out.println("Good");
break;
default:
System.out.println("Invalid grade");
}
ماذا سيكون المخرج للشفرة البرمجية جافا التالية التي تستخدم جملة switch-case؟
Which of the following is not a principle of Object-Oriented Programming?
Anonymous Quiz
14%
Encapsulation
9%
Inheritance
69%
Compilation
7%
Polymorphism
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());
}
}
ما هو مخرج الشفرة البرمجية جافا التالية التي توضح مفهوم الوراثة وإعادة تعريف الطريقة؟
👍1
Do you enjoy reading this channel?
Perhaps you have thought about placing ads on it?
To do this, follow three simple steps:
1) Sign up: https://telega.io/c/learn_java_e
2) Top up the balance in a convenient way
3) Create an advertising post
If the topic of your post fits our channel, we will publish it with pleasure.
Perhaps you have thought about placing ads on it?
To do this, follow three simple steps:
1) Sign up: https://telega.io/c/learn_java_e
2) Top up the balance in a convenient way
3) Create an advertising post
If the topic of your post fits our channel, we will publish it with pleasure.
Telega
Advertising in the Telegram channel «Learn java تعلم جافا» 09f6e - Telega.io
Advertising in the telegram channel Learn java تعلم جافا with a guarantee of placement! Telegram channel «@learn_java_e». Category: Computer science. Subscribers: 7081. Cost of advertising publication: $28.80.
How do you correctly handle exceptions in Java?
Anonymous Quiz
63%
try { } catch (Exception e) { }
20%
try { } except (Exception e) { }
9%
try { } error (Exception e) { }
8%
try { } catch (Error e) { }
❤2👍2
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 keyword is used to pass an object of a class as its own parameter?
Anonymous Quiz
68%
this
4%
self
15%
class
12%
super
What will be the output of the following Java program that demonstrates the concept of inheritance?
ماذا سيكون المخرج للبرنامج جافا التالي الذي يوضح مفهوم الوراثة؟
class Animal {
String sound() { return "Some sound"; }
}
class Dog extends Animal {
String sound() { return "Bark"; }
}
public class TestInheritance {
public static void main(String[] args) {
Animal myDog = new Dog();
System.out.println(myDog.sound());
}
}
ماذا سيكون المخرج للبرنامج جافا التالي الذي يوضح مفهوم الوراثة؟
👍1
How do you achieve abstraction in Java?
Anonymous Quiz
74%
By using abstract classes and interfaces
10%
By using static methods
7%
By using private constructors
9%
By using final classes
Identify and fix the error in the following Java code snippet that attempts to implement polymorphism.
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ الشكلية البوليمورفية.
interface Shape {
void draw();
}
class Circle implements Shape {
public void draw() {
System.out.println("Circle drawn");
}
}
public class TestPolymorphism {
public static void main(String[] args) {
Shape shape = new Circle();
shape.draw();
}
}
حدد وأصلح الخطأ في الشفرة البرمجية جافا التالية التي تحاول تنفيذ الشكلية البوليمورفية.
How do you convert a string to an integer in Java?
Anonymous Quiz
47%
Integer.parseInt("123")
30%
Integer.toString("123")
14%
String.toInt("123")
9%
"123".toInt()
❤2