Perl Online Quiz


Following quiz provides Multiple Choice Questions (MCQs) related to Perl. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 2 - 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 3 - 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.

Answer : A

Explanation

Adding a new key/value pair can be done with one line of code using simple assignment operator.

Q 5 - Which of the following operator performs exponential (power) calculation on operators?

A - *

B - /

C - %

D - **

Answer : D

Explanation

** − Exponent − Performs exponential (power) calculation on operators.

Q 6 - Which of the following operator returns true if the left argument is stringwise less than the right argument?

A - lt

B - gt

C - le

D - ge

Answer : A

Explanation

lt − Returns true if the left argument is stringwise less than the right argument.

Q 7 - Which of the following operator encloses a string with-in double quotes?

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : B

Explanation

qq{ } − Encloses a string with-in double quotes.

Q 8 - What is the default scope of perl variables?

A - global

B - private

C - protected

D - friend

Answer : A

Explanation

By default, all variables in Perl are global variables, which means they can be accessed from anywhere in the program.

Q 10 - Which of the following code create a reference for a array?

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : B

Explanation

You can create a reference for any array by prefixing it with a backslash as follows - $ref = \@ARGV;

perl_questions_answers.htm
Advertisements