Search Header Logo

Java-ArrayMethod

Authored by Kiều Thị

Fun, Professional Development

1st - 5th Grade

Used 33+ times

Java-ArrayMethod
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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();

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?