Java and Perl Programming Concepts Quiz
Test your knowledge of Java programming concepts including interfaces, collections, and error handling, along with Perl programming language features including regular expressions, arrays, and object-oriented programming.
Questions
What will be the value of $size after executing the following code?my @a = (0, 1, 2);$#a = 0;my $size = @a;
- undef
- 0
- 1
- 2
What elements will the @a array consist of? $_ = ' a b c '; my @a = split();
- ', 'a', ' ', 'b', ' ', 'c', ' '
- ', 'a', 'b', 'c', ''
- undef, 'a', 'b', 'c', undef
- 'a', 'b', 'c'
package A; sub NEW { bless {}, shift } sub AUTOLOAD { print ref(shift) } package main; my $obj = NEW A; $obj->foo();
- A
- AA
- Can't locate object method "foo" via package "A"
- none of the above
my $a = '123'; my $b = '0123'; if ($a == $b) { print "same"; } else { print "different"; }
- same
- different
- the code is ill-formed
- none of the above
In Perl, a/n ________ is a special character or a sequence that will define the number of times the previous character or sequence appears.
- character class
- metacharacter
- assertion
- quantifier
In Perl, 'stat' returns a thirteen element array with which of the following values?
- Last access
- Inode number
- Both of the above
- Perl Version ID
Which of the following is the correct way of sorting an array of integers in ascending order?
- sort @a
- sort {$1 <=> $2} @a
- sort {$a <=> $b} @a
- sort {$_[0] <=> $_[1]} @a
What gets printed? my @a = ([1, 2, 3, 4], [5, 6, 7, 8]); print join(' ', @{$a[1]}[1..3]);
- 1 2 3
- 2 3 4
- 5 6 7
- 6 7 8
All three ways of calling new() are equivalent in the code below package A; sub new { my ($class, $param) = @_; return bless {param => $param}, $class; } package main; my $a1 = A->new('foo'); my $a2 = new A('foo'); my $a3 = A::new('A', 'foo');
- True
- False
Which regular expression deletes all tags specified as text enclosed by "<" and ">" from a document stored in a string, but deletes nothing else?
- $string =~ s/<*&>//g;
- $string =~ s/<\s*>//g;
- $string =~ s/<.*?>//g;
- $string =~ s/<.*>//g;
sorted map is
- interface
- class
- Object
- None of these
SortedSet can implement
- set
- ConcurrentSkipListSet
- Hashmap
- Queue
RandomAccess interface is found in
- java.io
- java.util
- javax.xml.stream
- java.io.*
Compile time error can
- Handle with try catch block
- Handle with Throwable class
- Both of above true
- None of above