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

Answer : A

Explanation

Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which we will see in the upcoming chapters.

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 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 : B

Explanation

To remove an element from the hash you need to use delete function.

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 or equal to the right argument?

A - lt

B - gt

C - le

D - ge

Answer : D

Explanation

ge − Returns true if the left argument is stringwise greater than or equal to the right argument.

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 - Which of the following function returns the current local time on the machine that runs the script?

A - localtime

B - gmtime

C - time

D - strftime

Answer : A

Explanation

localtime − returns the current local time on the machine that runs the script.

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