Home / Programming Questions / Perl MCQs / Page 2

Perl MCQs with answers Page - 2

Dear candidates you will find MCQ questions of Perl here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

N

Nisha Gupta • 2.32K Points
Master

Q. Method in Perl is?

(A) Time savers
(B) User to reuse code w/o retyping the code
(C) Collections of statement that perform specific tasks
(D) All of these

N

Nisha Gupta • 2.32K Points
Master

Q. Is the following statement correct for Perl?
"Data Abstraction displays only the essential details to the user"

(A) true
(B) false
(C) ---
(D) ---

N

Nisha Gupta • 2.32K Points
Master

Q. What is the correct syntax for defining a class in Perl?

(A) package class_name
(B) class class_name
(C) new class class_name
(D) new package class_name

N

Nisha Gupta • 2.32K Points
Master

Q. Object in Perl an instance of a class?

(A) True
(B) False
(C) ---
(D) ---

N

Nisha Gupta • 2.32K Points
Master

Q. What is called when an object is created in Perl?

(A) Destructor
(B) Constructor
(C) Variable
(D) All of these

N

Nisha Gupta • 2.32K Points
Master

Q. What is the correct syntax for creating a new object in Perl?

(A) var object_name = new class_name()
(B) new object_name = class_name()
(C) my object_name = new class_name()
(D) None of these

N

Nisha Gupta • 2.32K Points
Master

Q. Which of these is not a type of method in Perl?

(A) Static method
(B) Constant method
(C) Virtual method
(D) All of these

N

Nisha Gupta • 2.32K Points
Master

Q. What will be the output of the following Perl code?

Code:
use strict;
use warnings;
package vehicle;

sub set_mileage{
    my $class = shift;
    
    my $self = {
        'distance'=> shift,
        'petrol_consumed'=> shift
    };
    
    bless $self, $class;
    return $self;
}

sub get_mileage{
    my $self = shift;
    my $result = $self->{'distance'} / $self->{'petrol_consumed'};
    
    print "$result\n";
}

my $ob1 = vehicle -> set_mileage(2550, 175);
$ob1->get_mileage();
(A) 15
(B) 15.00
(C) 14.5714285714286
(D) None of these

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.