Câu 1: Cho biết kết quả của đoạn mã sau:
int a1[] = {1,3,4,5};
int a2[][] = {{1,2,3},{4,5,6}};
a1[1] = a2[2][1];
a1[4] = a2[2][2];
for(int i = 0;i<a1.length;i++){
System.out.println(a1[i]);
}
Java-ArrayMethod
Quiz
•
Fun, Professional Development
•
1st - 5th Grade
•
Medium
Kiều Thị
Used 33+ times
FREE Resource
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Câu 1: Cho biết kết quả của đoạn mã sau:
int a1[] = {1,3,4,5};
int a2[][] = {{1,2,3},{4,5,6}};
a1[1] = a2[2][1];
a1[4] = a2[2][2];
for(int i = 0;i<a1.length;i++){
System.out.println(a1[i]);
}
Lỗi biên dịch
Xảy ra lỗi ArrayIndexOutOfBoundsException
1,5,4,5
1,5,4,5,6
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Lệnh nào để lấy ra độ dài của mảng là gì ?
length
size()
length()
size
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Cho biết kết quả của đoạn mã sau?
int[] x = {1, 3, 7, 9};
for(int a : x){
System.out.print(a);
if(a % 2 != 0){
break;
}
}
1, 3, 5, 7
1
3, 5, 7
Không có đáp án đúng
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Cho biết kết quả của đoạn mã sau?
int[] x = {5,6,7,8,9};
for(int a : x){
System.out.print(a) ;
}
5,6,7,8
5,6,7,8,9
a, a, a, a, a
a
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Cho biết kết quả đoạn mã sau:
int index = -1, a[] = {1,2,3,4};
for(int i=0;i<a.length();i++){
if(a[i] == 2){
index = i;
}
}
0
1
Lỗi biên dịch
2
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Cho biết kết quả của đoạn mã sau:
public static int tinhTong(int a[]){
int s = 0;
for (int i = 0;i<a.length;i++){
s+= a[i];
}
return s;
}
public static void main(String[] args) {
int a[] = {1,3,4,5};
System.out.println(tinhTong(a));
}
Lỗi biên dịch
13
12
10
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Khai báo nào sau đây có kiểu trả về là true/false?
public static boolean a();
public static int a();
public static long a1();
public static void a();
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Cho biết kết quả của đoạn mã sau?
static void swap(int i,int j){
int temp=i;
i=j;
j=temp;
}
public static void main(String[] args){
int i=1;
int j=2;
swap(i,j);
System.out.println( i + " j = " + j);
}
1, 2
2, 1
1, 1
2, 2
10 questions
Classic Cars
Quiz
•
KG - 12th Grade
10 questions
Reglas de baloncesto
Quiz
•
KG - 1st Grade
10 questions
Session Quiz FEB
Quiz
•
1st Grade
7 questions
Car Brands
Quiz
•
3rd Grade
10 questions
ôn toán
Quiz
•
3rd Grade
7 questions
Ôn tập kế thừa ép kiểu
Quiz
•
1st - 5th Grade
10 questions
Java Quiz
Quiz
•
3rd Grade
11 questions
Excel Game
Quiz
•
3rd Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
25 questions
SS Combined Advisory Quiz
Quiz
•
6th - 8th Grade
40 questions
Week 4 Student In Class Practice Set
Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025
Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)
Quiz
•
9th - 12th Grade
15 questions
June Review Quiz
Quiz
•
Professional Development
20 questions
Congruent and Similar Triangles
Quiz
•
8th Grade
25 questions
Triangle Inequalities
Quiz
•
10th - 12th Grade