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 1 - 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 2 - 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 4 - Which of the following statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating?

A - next

B - last

C - continue

D - redo

Answer : A

Explanation

next statement − Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Q 5 - Which of the following operator divides left hand operand by right hand operand and returns remainder?

A - *

B - /

C - %

D - **

Answer : C

Explanation

% − Modulus − Divides left hand operand by right hand operand and returns remainder.

Q 6 - Which of the following operator checks if the value of two operands are equal or not, and returns -1, 0, or 1?

A - ==

B - !=

C - <=>

D - >

Answer : C

Explanation

<=> − Checks if the value of two operands are equal or not, and returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument.

Q 7 - Which of the following operator increases integer value by one?

A - .

B - x

C - ..

D - ++

Answer : D

Explanation

++ − Auto Increment operator increases integer value by one.

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 9 - Which of the following operator is used when the current value of a variable must be visible to called subroutines?

A - my

B - local

C - state

D - None of the above.

Answer : B

Explanation

The local is used when the current value of a variable must be visible to called subroutines.

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

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : C

Explanation

You can create a reference for any hash by prefixing it with a backslash as follows - $ref = \%ENV;

perl_questions_answers.htm
Advertisements