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 - Is perl a case sensitive language?

A - true

B - false

Answer : A

Explanation

Perl is a case sensitive programming language. Thus $Manpower and $manpower are two different identifiers in Perl.

Q 2 - Which of the following special variable represents current file name?

A - FILE

B - _FILE_

C - file

D - None of the above.

Answer : B

Explanation

_FILE_ -represents current file 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.

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 statement repeats a statement or group of statements until a given condition becomes true. It tests the condition before executing the loop body?

A - while

B - until

C - for

D - None of the above.

Answer : B

Explanation

until loop − Repeats a statement or group of statements until a given condition becomes true. It tests the condition before executing the loop body.

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

A - <

B - >=

C - <=

D - <=>

Answer : C

Explanation

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

Q 7 - Which of the following operator encloses a string with-in invert quotes?

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : C

Explanation

qx{ } − Encloses a string with-in invert quotes.

Q 8 - Which of the following operator derefereces a variable?

A - --

B - ->

C - ..

D - ++

Answer : B

Explanation

-> − The arrow operator is mostly used in dereferencing a method or variable from an object or a class name.

Q 9 - Which of the following function opens a file in read-only mode?

A - open(DATA, "<file.txt");

B - open(DATA, ">file.txt");

C - open(DATA, "+>file.txt");

D - None of the above.

Answer : A

Explanation

open(DATA, "<file.txt"); − opens a file in read-only mode.

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