Perl and C++ Programming Quiz

Quiz covering Perl programming concepts including object destruction, string handling, regular expressions, and C++/Java language comparisons

10 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

C++ provides facility to specify that the compiler should match function calls with the correct definition at the run time. This process is called as

  1. Static binding
  2. Dynamic binding
  3. -
  4. --
Question 2 Multiple Choice (Single Answer)

In Java, to copy the contents of a to a new Foo object b

  1. Foo b = a;
  2. Foo b = a.clone();
  3. Foo b;b=a;
  4. -
Question 3 Multiple Choice (Single Answer)

In C++, this pointer is used by the symbol___

  1. . (dot)
  2. ,
  3. ->
  4. >
Question 4 True/False

C++ is normally compiled directly to machine code which is then executed directly by the operating system

  1. True
  2. False
Question 5 Multiple Choice (Single Answer)

In Java ,the statement Foo d = c; binds d to reference the same object as c, what will be equivalent statement in C++

  1. Foo d = c;
  2. Foo *d = c;
  3. Foo d; d=c;
  4. --
Question 6 Multiple Choice (Single Answer)

/de{0,3}/ matches

  1. df
  2. def
  3. deef
  4. deeef
  5. all the above
Question 7 Multiple Choice (Single Answer)

To copy entire matched sequence

  1. $&
  2. $%
  3. $_
  4. $@
  5. $^
Question 8 Multiple Choice (Single Answer)

$input = “abdce” =~ tr/abc/123 print $input;

  1. 123
  2. 123ce
  3. Cant modify constant item in translation
  4. 12d3e
  5. None of the above
Question 9 Multiple Choice (Single Answer)

$string = “\uhello world!”; print $string; $string = “\Uhello world!”; print $string;

  1. Hello world HELLO WORLD.
  2. Hello World HELLO WORLD.
  3. Hello world HELLO world.
  4. hello world HELLO WORLD.
Question 10 Multiple Choice (Single Answer)

package A; sub new { return bless {}, shift; } sub DESTROY { print ref(shift); } package B; use base 'A'; sub DESTROY { my $self = shift; print ref($self); bless $self, 'A'; } package main; my $obj = B->new();

  1. BA
  2. AB
  3. Compilation Error
  4. Null point reference error