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.
Questions
What will be output ? my $val = 'x'; print ref($val);
- STRING
- SCALAR
- Empty Value
- Not a Reference
What will be the output ? my $val = bless {}, 'MyClass'; print ref($val);
- TRUE
- MyClass
- 1
- Object Reference
What will be the size of the @data array ? my $var = ':x:y:z:'; my @data = split(':', $var, -1);
- 0
- 3
- 1
- 5
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";
- blah
- Empty String
- Can't locate object method "new" via package "B"
- None of the above
What will be the value of $keys ? my $var; if (exists $var->{key1}->{key2}) { $var->{key1}->{key2} = 1; } my $keys = keys(%{$var});
- code will fail
- 2
- 1
- undef
What will be the output ? my $str = 'a\b\n'; print $str;
- ab(newline)
- a\b\n
- a\b(newline)
- a\b\n
What will be the value of $str ? my $str = '112133'; $str =~ s/(.)\1/$1/g;
- 112133
- 1233
- 1213
- 12133
What will the contents of @b array ? my @a = (10, 5, 1); my @b = sort @a;
- (1, 5, 10)
- (1, 10, 5)
- (10, 5, 1)
- (5, 10, 1)
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.
- my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
- my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
- my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')"); $statement->execute;
- my $statement = $dbh->sql("INSERT INTO names VALUES ('John')"); $statement->execute;
What will be the output ? my $pattern = '.*'; $str =~ /(\Q$pattern\E)/;
- any number of any characters
- any number of any characters surrounded by Q and E
- literally \Q.*\E
- literally .*
Select the events available for a gridview/datagrid
- RowDataBound
- ItemDataBound
- RowClick
- ItemClick
Which of the following are said to be assemblies.
- .vb
- .dll
- .aspx
- .exe
what are the namespace/classes related Database operation?
- System.Data
- System.Data.Dataset
- System.Data.SQLClient
- System.Data.Datareader
The different types of assemblies are private, public, shared, unshared, satellite.
- True
- False
An application can have more than 2 Global.asax files.
- True
- False
Following code will result in: int a1 = 5; double a2 = (float)a1;
- Compilation error
- Runtime error
- No errors
- Compilation error at statement 2
Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}
- Compilation error
- Runtime Error
- Runtime Exception
- Output of b is 1
Following code will result in: class A { public static void main(String [] args) {B b = new A(); }} class B extends A {}
- Compile error
- Runtime Exception
- No error
- Compile error. Type mismatch: cannot convert from A to B
Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?
- Compiler error
- Runtime Exception
- True
- False
Methods that are marked protected can be called in any subclass of that class.
- True
- False