Bash Array Quiz

Bash Array Quiz

University

10 Qs

quiz-placeholder

Similar activities

Lesson 3: Variables Part 1

Lesson 3: Variables Part 1

University

7 Qs

Fundamentos de Shell Script

Fundamentos de Shell Script

11th Grade - University

12 Qs

Flutter intro and Dart quiz

Flutter intro and Dart quiz

University

15 Qs

One Dimensional Array

One Dimensional Array

University

10 Qs

PHP Module 1 Unit Test

PHP Module 1 Unit Test

University

15 Qs

PHP - Syntax & Output

PHP - Syntax & Output

University

15 Qs

LINUX MODULE 03 QUIZ

LINUX MODULE 03 QUIZ

University

10 Qs

Python Basics

Python Basics

University

10 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?