Mason (Perl)/Perl Programming MCQs Set 1 Sample Test,Sample questions

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

1.TRUE

2.FALSE

3.Error

4.None of These


Question:
 Advantages of encapsulation are -

1.Data hiding

2.Reusability

3.Ease of testing

4.All of the above


Question:
 Is boolean type provided in Perl?

1.Yes

2.No

3.Error

4.None of these


Question:
 keyword is used to ___.

1.Create an alias to package

2.Create a new variable

3.Create a virtual variable

4.None of these


Question:
 What are the disadvantages of Perl over C/C++?

1.No main() [driver] function

2.Support closures

3.It is interpreted language

4.None of these


Question:
 What is method overwriting in Perl?

1.Filling up method with extra written data

2.Methods that provide extra features

3.A Feature that allows rewriting of methods in child class

4.All of the above


Question:
 Which of these is the 'True' value in Perl?

1.""

2.0

3.5

4.All of These


Question:
'%b' in the Perl output statement used to?

1.Print backspace character

2.Print binary of a number

3.Print the statement in bold in web

4.None of These


Question:
'x' operator on string used to?

1.Add x character to the string

2.Repeat the given string multiple times

3.Add two strings

4.None of these


Question:
A Feature that allows rewriting of methods in child class

1.TRUE

2.FALSE

3.Error

4.None of These


Question:
A group of statements that perform a specific task is known as ___.



1.Function

2.Subroutine

3.Method

4.All of the above


Question:
Arguments in Perl are passed as ___.

1.Values

2.Strings

3.Array

4.All of the above


Question:
Destructor's in Perl are ___.

1.Used for cleanup of reference of objects

2.Called at the start of the program

3.Not a program

4.All of the above


Question:
Do we need to specify the data type of a variable in Perl?

1.Yes

2.No

3.Error

4.None of these


Question:
Encapsulation is also known as?

1.Polymorphism

2.Method overloading

3.Data hiding

4.None of these


Question:
Global scope variables can be used -

1.Inside any function or block

2.Inside a specific function

3.Inside a specific block

4.None of these


Question:
Is return type required for a subroutine in Perl?

1.Yes

2.No

3.Error

4.None of These


Question:
Logical operators in Perl are ___.

1.Used to compare values

2.Used to combine conditions

3.Used to perform arithmetic operations

4.None of These


Question:
Perl Programming language is ___?



1.General purpose programming language

2.Dynamic programming language

3.High-level interpreted programming language

4.All of the above


Question:
Scalar variables in Perl are ___.

1.Array values

2.A Single unit of data

3.String Values

4.All of the above


Question:
The chdir() function used to ___.

1.Change directory

2.Remove directory

3.Create directory

4.None of These


Question:
The creator of Perl programming language is ___.

1.James Gosling

2.Brendan Eich

3.Larry Wall

4.Bjarne Stroustrup


Question:
The result of the following operation is -

100 << 3

1.001

2.300

3.800

4.Error


Question:
The year in which Perl was launched?

1.1986

2.1987

3.1988

4.1978


Question:
What are 'listary operators' in Perl?

1.Operator on collections

2.Operators on integers

3.Operators on the list of operators

4.All of the above


Question:
What are the benefits of the Perl programming language?

1.Easy to learn

2.Text Processing

3.Easy to be embedded on web pages

4.All of the above


Question:
What is a directory in Perl?

1.A place to store values in the form of a list

2. An array to string

3.A data structure

4.None of These


Question:
What is a module in Perl?

1.Collection of related subroutines and variables

2.Array of functions

3.Collection of values of same type

4.None of these


Question:
What is a number in Perl?

1.Mathematical object for counting, measuring, and performing mathematical operations

2.math module

3.Non string type

4.All of the above


Question:
What is called when an object is created in Perl?



1.Destructor

2.Constructor

3.Variable

4.All of the above


Question:
What is encapsulation in Perl?

1.Creating Arrays

2.Wrapping up data and related methods to a single unit

3.Creating separate structures storing values

4.All of these


Question:
What is multilevel inheritance in Perl?

1.A subclass of a class is inherited by another class

2.A class inherits properties from multiple classes

3.Multiple classes inherit properties from a class

4.None of the above


Question:
What is multiple inheritance in Perl?

1.When more than two different inheritance takes place in a single program.

2.When a class inherits more than two classes

3.When two classes inherit properties from a single class

4.None of these


Question:
What is polymorphism in Perl?

1.Creating multiple constants with the same name

2.Defining multiple methods under the same name

3. Creating multiple variables with the same name

4.All of the above


Question:
What is the correct operator precedence for the following operators?

    && , &, = , ->

1.& , && , = , ->

2.-> , & , && , =

3.= , & , && , ->

4.= , -> , && , &


Question:
What is the correct syntax for creating a new object in Perl?

1.var object_name = new class_name()

2.new object_name = class_name()

3.my object_name = new class_name()

4.None of these


Question:
What is the correct syntax for defining a class in Perl?

1.package class_name

2.class class_name

3.new class class_name

4.new package class_name


Question:
What is the file extension for the Perl program?

1. .pl

2..perl

3..prl

4.None of these


Question:
What is the syntax to create multiline comments in Perl?

1.=start =end

2.#begin #cut

3.=begin =cut

4.None of these


Question:
What will be the output of the following Perl code?

$m = 2;

if ($m){
    print "True";
}
else{
    print "False";
}

1.True

2.False

3.Error

4.None of the these


Question:
What will be the output of the following Perl code?

$val1 = 5;
$val2 = 10;

$result = $val1 == $val2 ? $val1 : $val2;

print "$result"

1.5

2.15

3.10

4.20


Question:
What will be the output of the following Perl 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
";
}

my $ob1 = vehicle -> set_mileage(2550, 175);
$ob1->get_mileage();

1.15

2.15.00

3.14.5714285714286

4.None of These


Question:
Which escape sequence is used to print hexadecimal of a number in Perl?

1.%h

2.%b

3.%hex

4.%x


Question:
Which method in Perl is used to delete a directory?

1.deldir

2.rmdir

3.cldir

4.chdir


Question:
Which of the following is a type of operator in Perl?

1.Arithmetic Operator

2.Relational Operator

3.Ternary Operator

4.All of the above


Question:
Which of the following is a valid assignment operator in Perl?

1.=

2.==

3.+=

4. %=


Question:
Which of the following is not a concept of OOP?

1.Encapsulation

2.Class

3.Abstraction

4.None of these


Question:
Which of the following operations can be performed on directories?

1.Creating directory

2.Closing directory

3.Changing directory path

4.All of the above


Question:
Which of these are valid type of inheritance in Perl?

1.Multiple inheritance

2.Multilevel inheritance

3.Hierarchical inheritance

4.All of the above


Question:
Which of these is a valid way to define a function in Perl?

1.returntype function_name{ }

2.sub function_name{ }

3.function function_name{ }

4.None of These


Question:
Which of these is a valid way to start a variable?

1.$

2.@

3.%

4.All of the above


Question:
Which of these is not a basic data type in Perl?

1.Integer

2.Arrays

3.Scalars

4.None of These


Question:
Which of these is not a type of method in Perl?

1.Static method

2. Constant method

3.Virtual method

4.All of the above


Question:
Which statement in Perl is used to import a module?

1.import module_name

2.include module_name

3.use module_name

4.None of these


Question:
Which statement is used to enable strict mode in Perl?

1.Strict mode;

2.use strict;

3.use strict mode;

4.None of these


More MCQS

  1. Perl Programming MCQs Set 1
  2. Perl Programming MCQs Set 2
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!