Bash Array Quiz

Bash Array Quiz

University

10 Qs

quiz-placeholder

Similar activities

docker advance

docker advance

University

13 Qs

CHAPTER 7 - PHP

CHAPTER 7 - PHP

University

10 Qs

PHP with MySQL quiz

PHP with MySQL quiz

University

15 Qs

UMS - Refresment Array, Looping, Function

UMS - Refresment Array, Looping, Function

University

15 Qs

PHP Basics

PHP Basics

University

10 Qs

PHP

PHP

University

10 Qs

LINUX MODULE 03 QUIZ

LINUX MODULE 03 QUIZ

University

10 Qs

Basic Java

Basic Java

University

15 Qs

Bash Array Quiz

Bash Array Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Amal Redge

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare an array in Bash?

array_name = (value1 value2 value3)

array_name = [value1 value2 value3]

array_name = {value1 value2 value3}

array_name =

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to access the third element of an array named my_array?

${my_array[2]}

${my_array[3]}

${my_array[1]}

${my_array[0]}

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which command is used to get the length of an array in Bash?

${#array_name}

${array_name[@]}

${#array_name[@]}

${array_name[*]}

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you append a value to an existing array in Bash?

array_name += value

array_name[] = value

array_name += (value)

array_name+=(value)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? array=(1 2 3 4 5) echo ${array[@]:1:3}

1 2 3

2 3 4

3 4 5

2 3 4 5

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you iterate over all elements of an array named my_array?

for i in ${my_array[*]}; do echo $i; done

for i in ${my_array[@]}; do echo $i; done

for i in ${my_array}; do echo $i; done

for i in ${my_array[0]}; do echo $i; done

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct way to declare an associative array in Bash?

declare -A array_name

declare -a array_name

declare -A array_name[]

declare -a array_name[]

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?