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

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 statement jumps to the statement labeled with LABEL and resumes execution from there?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : A

Explanation

goto LABEL − The goto LABEL form jumps to the statement labeled with LABEL and resumes execution from there.

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

A - lt

B - gt

C - le

D - ge

Answer : B

Explanation

gt − Returns true if the left argument is stringwise greater than the right argument.

Q 7 - Which of the following operator returns a string consisting of the left operand repeated the number of times specified by the right operand?

A - .

B - x

C - ..

D - ++

Answer : B

Explanation

x − The repetition operator x returns a string consisting of the left operand repeated the number of times specified by the right operand.

Q 8 - Which of the following function returns the universal Greenwich Mean Time, or GMT (or UTC)?

A - localtime

B - gmtime

C - time

D - strftime

Answer : B

Explanation

gmtime − returns the universal Greenwich Mean Time, or GMT (or UTC).

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