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

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 checks if the value of two operands are equal or not, if yes then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : A

Explanation

== − Checks if the value of two operands are equal or not, if yes then condition becomes true.

Q 6 - Which of the following operator checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true?

A - <

B - >=

C - <=

D - <=>

Answer : B

Explanation

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

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

A - --

B - ->

C - ..

D - ++

Answer : A

Explanation

-- − Auto Decrement operator decreases integer value by one.

Q 8 - Parameters of a function can be acessed inside the function using the special array @_?

A - true

B - false

Answer : A

Explanation

Parameters can be acessed inside the function using the special array @_. Thus the first argument to the function is in $_[0], the second is in $_[1], and so on.

Q 10 - Which of the following function disassociate the filehandle from the corresponding file?

A - close

B - unlink

C - seek

D - None of the above.

Answer : A

Explanation

close − To close a filehandle, and therefore disassociate the filehandle from the corresponding file, you use the close function. This flushes the filehandle's buffers and closes the system's file descriptor.

perl_questions_answers.htm
Advertisements