Skip to content

Instantly share code, notes, and snippets.

@pradhuman7d1
Created December 6, 2021 11:07
Show Gist options
  • Save pradhuman7d1/6799e03cbfc206449888eb2dfa0cc73d to your computer and use it in GitHub Desktop.
Save pradhuman7d1/6799e03cbfc206449888eb2dfa0cc73d to your computer and use it in GitHub Desktop.
PERL-OOPS
Q. What is inheritance?
A. The process by which a class can use the properties and methods of another class by inheriting it is inheritance.
Q. What is a ".pm" file?
A. A ".pm" file is a package file for a perl script, pm stands for perl module, it can be used to write code for some specific task and call it from main script.
Q. What is the use of '->'?
A. This notation is used to access or create a perticular object in a class.
Q. How we can create and use a class?
A. A class is created inside a module that is then used in the program using the 'use' keyword, if we want to inherit a class then create two modules
one containing the parent class and other containing the inherited class, also 'use' keyword is used to use attributes of parent class in child.
Q. What is the use of this line of code?
my $class = shift;
a. stores argument array in scalar variable
b. stores attributes in scalar variable
c. stores the class package in scalar variable
d. none of these.
A. c. stores the class package in scalar variable
Q. What is the use of 'bless' keyword?
a. to return the class
b. to convert hash reference into object
c. to create new objects
d. none of these.
A. b. to convert hash reference into object
Q. What is @ISA ?
a. an array that stores a list of parent classes.
b. an array that stores the objects of the class.
c. an array that stores the objects of the parent class.
d. none of these.
A. a. an array that stores a list of parent classes.
Q. Which of these is the correct syntax for object creation?
1. my $john = Employee::SDE->new("John", "Software Developer", 74000);
2. my $Jerry = new Employee::SDE("Jerry", "UI Designer, 58000");
a. 1
b. 2
c. both 1 & 2
d. none of these
A. c. both 1 & 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment