Mixed Programming Languages: Java, .NET, and Perl

Test your knowledge across multiple programming languages including Java, .NET/ASP.NET, and Perl with questions covering core concepts, OOP, and practical programming scenarios.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What will be output ? my $val = 'x'; print ref($val);

  1. STRING
  2. SCALAR
  3. Empty Value
  4. Not a Reference
Question 2 Multiple Choice (Single Answer)

What will be the output ? my $val = bless {}, 'MyClass'; print ref($val);

  1. TRUE
  2. MyClass
  3. 1
  4. Object Reference
Question 3 Multiple Choice (Single Answer)

What will be the size of the @data array ? my $var = ':x:y:z:'; my @data = split(':', $var, -1);

  1. 0
  2. 3
  3. 1
  4. 5
Question 4 Multiple Choice (Single Answer)

What will be the output ? package A; sub new { my $class = shift; return bless {}, $class; } package B; use base 'A'; sub foo { return 'blah'; } package main; my $obj = B->new(); print $obj->foo(), "\n";

  1. blah
  2. Empty String
  3. Can't locate object method "new" via package "B"
  4. None of the above
Question 5 Multiple Choice (Single Answer)

What will be the value of $keys ? my $var; if (exists $var->{key1}->{key2}) { $var->{key1}->{key2} = 1; } my $keys = keys(%{$var});

  1. code will fail
  2. 2
  3. 1
  4. undef
Question 6 Multiple Choice (Single Answer)

What will be the output ? my $str = 'a\b\n'; print $str;

  1. ab(newline)
  2. a\b\n
  3. a\b(newline)
  4. a\b\n
Question 7 Multiple Choice (Single Answer)

What will be the value of $str ? my $str = '112133'; $str =~ s/(.)\1/$1/g;

  1. 112133
  2. 1233
  3. 1213
  4. 12133
Question 8 Multiple Choice (Single Answer)

What will the contents of @b array ? my @a = (10, 5, 1); my @b = sort @a;

  1. (1, 5, 10)
  2. (1, 10, 5)
  3. (10, 5, 1)
  4. (5, 10, 1)
Question 9 Multiple Choice (Single Answer)

Sample Code Code: INSERT INTO names VALUES ('John') How do you use the DBI module to execute the above SQL statement? Assume $dbh is the return value from DBI->connect.

  1. my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
  2. my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
  3. my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')"); $statement->execute;
  4. my $statement = $dbh->sql("INSERT INTO names VALUES ('John')"); $statement->execute;
Question 10 Multiple Choice (Single Answer)

What will be the output ? my $pattern = '.*'; $str =~ /(\Q$pattern\E)/;

  1. any number of any characters
  2. any number of any characters surrounded by Q and E
  3. literally \Q.*\E
  4. literally .*
Question 11 Multiple Choice (Multiple Answers)

Select the events available for a gridview/datagrid

  1. RowDataBound
  2. ItemDataBound
  3. RowClick
  4. ItemClick
Question 12 Multiple Choice (Multiple Answers)

Which of the following are said to be assemblies.

  1. .vb
  2. .dll
  3. .aspx
  4. .exe
Question 13 Multiple Choice (Multiple Answers)

what are the namespace/classes related Database operation?

  1. System.Data
  2. System.Data.Dataset
  3. System.Data.SQLClient
  4. System.Data.Datareader
Question 14 True/False

The different types of assemblies are private, public, shared, unshared, satellite.

  1. True
  2. False
Question 15 True/False

An application can have more than 2 Global.asax files.

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

Following code will result in: int a1 = 5; double a2 = (float)a1;

  1. Compilation error
  2. Runtime error
  3. No errors
  4. Compilation error at statement 2
Question 17 Multiple Choice (Single Answer)

Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

  1. Compilation error
  2. Runtime Error
  3. Runtime Exception
  4. Output of b is 1
Question 18 Multiple Choice (Single Answer)

Following code will result in: class A { public static void main(String [] args) {B b = new A(); }} class B extends A {}

  1. Compile error
  2. Runtime Exception
  3. No error
  4. Compile error. Type mismatch: cannot convert from A to B
Question 19 Multiple Choice (Single Answer)

Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?

  1. Compiler error
  2. Runtime Exception
  3. True
  4. False
Question 20 True/False

Methods that are marked protected can be called in any subclass of that class.

  1. True
  2. False