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

(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

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

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

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

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

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

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

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.