Perl Online Quiz


Advertisements


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 - 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 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.

Q 4 - Which of the following function returns true if the named key exists in a Hash?

A - check

B - exists

C - Both of the above.

D - None of the above.

Answer : B

Explanation

exists − exists function, which returns true if the named key exists, irrespective of what its value might be.

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 left operand is greater than the value of right operand, if yes then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : D

Explanation

> − Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

Q 7 - Which of the following operator concatenates two strings?

A - .

B - x

C - ..

D - ++

Answer : A

Explanation

. − Binary operator dot (.) concatenates two strings.

Q 8 - Which of the following function formats date and time?

A - localtime

B - gmtime

C - time

D - strftime

Answer : D

Explanation

strftime − formats date and time.

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

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : D

Explanation

You can create a reference for any subroutine by prefixing it with a backslash as follows - $ref = \&PrintHash;


perl_questions_answers.htm

Advertisements