b) In object oriented PERL the arrow -> symbol is used for creating or accessing a particular object of a class
c) Arrow operator -> is used for dereferencing references to array or hash
e.g $arr = ['1', '2' ,'3', '4'];
To retrieve the value of first element:
$val = $arr->[1];
d) All of the above are correct
Ques 2:
How do you open a file for writing?
a) open (”FH”, “>filename.dat”) || die “Can’t create the file\n”; Later use FH to perform all file related operation.
b) open (”FH”, “<filename.dat”) || die “Can’t create the file\n”; Later use FH to perform all file related operation.
c) open (”FH”, “filename.dat”) || die “Can’t create the file\n”; Later use FH to perform all file related operation.
d) All are same.
1
Expert's answer
2013-01-21T10:04:14-0500
Question 1:The correct answer is b).If you have an object $a of class MyClass, and classMyClass has property "prop", and method "meth", then one can access to them as follows: $a->prop $a->meth() Question 2: The correct answer is a), where symbol ">"is used. In the case b), with symbol "<" file will beopened for reading, while case c) is incorrect.
Comments
Leave a comment