Perl Mock Test



This section presents you various set of Mock Tests related to Perl. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Perl Mock Test I

Q 3 - Which of the following interpolates variables and special characters in Perl?

A - Single Quotes based String

B - Double Quotes based String

C - Both of the above.

D - None of the above.

Answer : B

Explanation

Only double quotes interpolate variables and special characters such as newlines , where as single quote does not interpolate any variable or special character.

Q 4 - Is perl a case sensitive language?

A - true

B - false

Answer : A

Explanation

Perl is a case sensitive programming language. Thus $Manpower and $manpower are two different identifiers in Perl.

Q 5 - Which of the following data type is suppported in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : D

Explanation

All of the above data types are supported in Perl.

Answer : A

Explanation

Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which we will see in the upcoming chapters.

Answer : B

Explanation

Arrays are ordered lists of scalars that you access with a numeric index which starts with 0. They are preceded by an "at" sign (@).

Answer : C

Explanation

Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They are preceded by a percent sign (%).

Q 9 - Which of the following data types are preceded by a dollar sign ($) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : A

Explanation

Scalars are preceded by a dollar sign ($).

Q 10 - Which of the following data types are preceded by an "at" sign (@) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : B

Explanation

Arrays are preceded by an "at" sign (@).

Q 11 - Which of the following data types are preceded by a percent sign (%) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : C

Explanation

Hashes are preceded by a percent sign (%).

Q 12 - In which of the following variable context, assignment to a scalar variable evaluates the right-hand side in a scalar context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : A

Explanation

Scalar − Assignment to a scalar variable evaluates the right-hand side in a scalar context.

Q 13 - In which of the following variable context, assignment to an array or a hash evaluates the right-hand side in a list context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : B

Explanation

List − Assignment to an array or a hash evaluates the right-hand side in a list context.

Q 14 - In which of the following variable context, an expression is being evaluated to see whether it's true or false?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : C

Explanation

Boolean − Boolean context is simply any place where an expression is being evaluated to see whether it's true or false.

Q 15 - Which of the following variable context doesn't care what the return value is?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : D

Explanation

Void − This context not only doesn't care what the return value is, it doesn't even want a return value.

Q 16 - Which of the following variable context only happens inside quotes, or things that work like quotes?

A - Interpolative

B - List

C - Boolean

D - Void.

Answer : A

Explanation

Interpolative − This context only happens inside quotes, or things that work like quotes.

Q 17 - Which of the following special variable represents current file name?

A - FILE

B - _FILE_

C - file

D - None of the above.

Answer : B

Explanation

_FILE_ -represents current file name.

Q 18 - Which of the following special variable represents current line number?

A - LINE

B - Line

C - _LINE_

D - None of the above.

Answer : C

Explanation

_LINE_ -represents current line number.

Q 19 - Which of the following special variable represents current package name?

A - _PACKAGE_

B - Package

C - PACKAGE

D - None of the above.

Answer : A

Explanation

_PACKAGE_ -represents current package name.

Q 21 - Which of the following method pushes the values of the list onto the end of the array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : A

Explanation

push @ARRAY, LIST − Pushes the values of the list onto the end of the array.

Q 22 - Which of the following method pops off and returns the last value of the array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : B

Explanation

pop @ARRAY - Pops off and returns the last value of the array.

Q 23 - Which of the following method shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : C

Explanation

shift @ARRAY − Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down.

Q 24 - Which of the following method prepends list to the front of the array, and returns the number of elements in the new array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : D

Explanation

unshift @ARRAY, LIST - Prepends list to the front of the array, and returns the number of elements in the new array.

Q 25 - Which of the following method remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified?

A - splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

B - split @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

C - join @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

D - sort @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

Answer : A

Explanation

splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ] - This function will remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified. Finally, it returns the elements removed from the array.

Answer Sheet

Question Number Answer Key
1 D
2 D
3 B
4 A
5 D
6 A
7 B
8 C
9 A
10 B
11 C
12 A
13 B
14 C
15 D
16 A
17 B
18 C
19 A
20 D
21 A
22 B
23 C
24 D
25 A
perl_questions_answers.htm
Advertisements