<pre>
int[] myArray = new int[] {1,2,3,4,5}
List myList = List myList = new [Link](m
</pre> List myList = [Link]();
[Link](myArray); ArrayList(myArray); yArray);
What Allows you to create a list from
the above array?
B
<pre>
<pre> <pre> <pre> class MinMax<E
class MinMax<E extends Comparable<E>> class MinMax<E implements class MinMax<E extends implements
A programmer must create a generic
{ Comparable<E>> { Comparable<E>> { Comparable<E>> {
class MinMax and the type
E min = null; E min = null; <E> E min = null; <E> E min = null;
parameter of MinMax must
E max = null; E max = null; <E> E max = null; <E> E max = null;
implement Comparable. Which
public MinMax() {} public MinMax() {} public MinMax() {} public MinMax() {}
implementation of MinMax will
public void put(E value) { /* store min or public void put(E value) { /* public <E> void put(E value) { /* public <E> void put(E
compile?
max */ } store min or max */ } store min or max */ } value) { /* store min or
</pre> </pre> </pre> max */ }
</pre> A
A programmer has an algorithm that
requires a [Link] that provides
an efficient implementation of add(0,
object), but does NOT need to [Link] [Link] [Link] [Link]
support quick random access. What
supports these requirements?
D
The Example values can
be used in a
The expression (ONE < TWO) is [Link], but
The Example values cannot be
The expressions (ONE == ONE) and guaranteed to be true and the set will NOT be
enum Example { ONE, TWO, THREE } used in a raw [Link];
[Link](ONE) are both guaranteed to [Link](TWO) is sorted because
Which statement is true? instead, the programmer must
be true. guaranteed to be less than enumerated types do
use a [Link].
one. NOT implement
[Link].
A
<pre>
1. public static void append(List list) {
[Link]("0042"); }
2. public static void main(String[]
args) {
3. List<Integer> intList = new An exception is thrown at Compilation fails because
42 0042
ArrayList<Integer>(); runtime. of an error in line 3.
4. append(intList);
5. [Link]([Link](0));
6. }
</pre>
What is the result?
B
In context to be below snippet
<pre>
[Link] enum Title {
2. MR("Mr."), MRS("Mrs."),
MS("Ms.");
3. private final String title;
4. private Title(String t) { title = t; }
5. public String format(String last,
String first) {
6. return title + " " + first + " " + last; An exception is thrown at Compilation fails because of an Compilation fails because
Mr. John Doe
7. } runtime. error in line 2. of an error in line 5.
8. }
9. public static void main(String[]
args) {
10.
[Link]([Link]("
Doe", "John"));
11. }
</pre>
What id the Result?
A
<pre>
1. class TestA {
2. public void start() {
[Link]("TestA"); }
3. }
4. public class TestB extends TestA {
5. public void start() {
An exception is thrown at
[Link]("TestB"); } TestA TestB Compilation fails.
runtime.
6. public static void main(String[]
args) {
7. ((TestA)new TestB()).start();
8. }
9. }
</pre>
What is the result?
B
<pre>
1. class Line {
2. public class Point { public int x,y;}
3. public Point getPoint() { return
new Point(); }
4. }
5. class Triangle {
[Link] p = (new
6. public Triangle() { Point p = [Link](); [Link] p = [Link](); Point p = (new Line()).getPoint();
Line()).getPoint();
7. // insert code here
8. }
9. }
</pre>
Which code, inserted at line 7,
correctly retrieves a local instance of
a Point object?
D
<pre>
1. public class MyLogger {
2. private StringBuilder logger = new
StringBuuilder();
3. public void log(String message,
String user) {
4. [Link](message); replace StringBuilder with just a No change is necessary,
5. [Link](user); replace StringBuilder with String object and use the string the current MyLogger
synchronize the log method
6. } StringBuffer concatenation (+=) within the log code is already thread‐
7. } method safe.
</pre>
The programmer must guarantee
that a single MyLogger object works
properly for a multi‐threaded system.
How must this code be changed to be
thread‐safe?
A
<pre>
1. public class Threads4 {
2. public static void main (String[]
args) {
3. new Threads4().go();
4. }
5. public void go() {
6. Runnable r = new Runnable() {
7. public void run() { The code executes
An exception is thrown at The code executes normally and
8. [Link]("foo"); Compilation fails. normally, but nothing is
runtime. prints "foo".
9. } printed.
10. };
11. Thread t = new Thread(r);
12. [Link]();
13. [Link]();
14. }
15. }
</pre>
What is the result? B
You have a very large XML file
containing around a million records
of a Type which is fairly large in size,
you want to read through each and
every record , but the constraint is SAX parser DOM Parser Linear Parser Language Parser
that your system does not have
sufficient RAM to load all the values
at once, which will be the best way to
parse that XML file
A
What is the Average case running
time of a quicksort algorithm, O(n) O(n2) O(n log n) O(n3)
running over a collection of n objects
C
You are to implement a window
token management system, in the
said system citizens will be coming to
a token window to get a token
number, afterwards you have 5
number of processing counters which
shall be processing these citizens one
by one, the only issue here is that the
token should be prioritized on the
basis of certain parameters which is
to be provided by citizen such as
serious crime, unidentified dead
LinkedList Heap Array Doubly Linked List
bodies, emergency, medico legal
cases etc. depending upon the
scenario the token window shall
assign a priority as well to the token,
every time a counter clears up the
highest priority token would be
picked up, if more than one token
have the same priority then the
earlier token should be picked up.
which among the following would be
the best choice for a data structure in
this case
B
NoSQL databases such as MongoDB,
Cassandra DB are being currently
used in Social networking and
ecommerce platforms, more and
more companies are slowly coming Transaction Isolation and Object level Object Oriented Database Indexing and full text
Unstructured Data Store Support
forward with their own version of Locking Support search features Support
NoSQL, what advantage is offered by
this currently hyped product which
was not provided by traditional
databases such as Oracle, MySQL etc
C
REST or representational state
transfer is a methodology which is
Reciprocal Equity State Random Engine based Servlet
used to create single page Representational State Transfer None of the Above
Topography Technology
application, what does the acronymn
REST stands for? A
Considering the below schema, there
is a table containing the following
structure
CRIME_DETAILS(CRIME_DETAILS_ID, SELECT
SELECT
FIR_REG_NUM,FIR_DATE,GD_NUM,G COUNT(CRIME_DETAILS_ID)
SELECT COUNT(CRIME_DETAILS_ID) FROM COUNT(CRIME_DETAILS_ID) None of the above
D_DATE,COMPLAINANT_ID,PS_CD,DI FROM CRIME_DETAILS WHERE
CRIME_DETAILS GROUP BY DISTRICT_CD FROM CRIME_DETAILS WHERE Queries will correctly
STRICT_CD,STATE_CD,GIST). GIST LIKE '%ROBERRY%' GROUP
HAVING GIST LIKE '%ROBERRY%'; GIST LIKE '%ROBERRY%' return the required data
Which of the below would be a BY DISTRICT_CD,PS_CD HAVING
GROUP BY DISTRICT_CD;
correct query to get the District wise PS_CD <> NULL;
count of all the incidents which
contain "ROBERRY" in the GIST
column.
B
There is a class Personnel which
includes the following fields(String
firstname,String lastName, Date
dateOfBirth,Date dateOfJoining,Date
basicSalary,Personnel
reportingOfficer),You are assigned a
task which involves creation of a
[Link] [Link] [Link] [Link]
personnel list , you need to compare
the personnel in runtime and arrange
them as per their seniority(early
joiner should come first), which of
the following can be IMPLEMENTED
by the Personnel class to achieve
this?
C
which of the following are the correct
representation of a double literal in
java
<pre>
1. 3.14f 1 and 2 2 and 3 2, 3, and 4 only 1
2. 3.14
3. 3.14d
4. 3.14D
</pre> C
<pre>
public static Iterator reverse(List list)
{
[Link](list);
return [Link]();
}
public static void main(String[] args) {
The code runs with no
List list = new ArrayList(); 3, 2, 1, 1, 2, 3, Compilation fails.
output.
[Link]("1"); [Link]("2");
[Link]("3");
for (Object obj: reverse(list))
[Link](obj + ", ");
}
</pre>
What is the result?
C
<pre>
[Link] A {
[Link] void process() {
[Link]("A,"); }
[Link] B extends A {
[Link] void process() throws
IOException {
[Link]();
[Link]("B,"); Compilation fails because of an A NullPointerException is
Exception A,B,Exception
[Link] new IOException(); error in line 4 thrown at runtime.
8.}
[Link] static void main(String[]
args) {
[Link] { new B().process(); }
[Link] (IOException e) {
[Link]("Exception"); }
</pre>
what is the result?
C
<pre>
1. try {
2. // some code here
3. } catch (NullPointerException e1) {
4. [Link]("a");
5. } catch (RuntimeException e2) {
6. [Link]("b");
c a ab ac
7. } finally {
8. [Link]("c");
9. }
</pre>
What is the result if a
NullPointerException occurs on line
2?
D
<pre>
public static Collection get() {
Collection sorted = new LinkedList();
[Link]("B"); [Link]("C");
[Link]("A");
return sorted;
} The code runs with no
A, B, C, B, C, A, Compilation fails.
public static void main(String[] args) { output.
for (Object obj: get()) {
[Link](obj + ", ");
}
}
</pre>
What is the result?
B
<pre>
1. public class Person {
2. private String name;
3. public Person(String name) { When adding Person
To work correctly with hash‐
[Link] = name; } Compilation fails because the objects to a [Link]
The equals method does NOT properly based data structures, this class
4. public boolean equals(Person p) { private attribute [Link] collection, the equals
override the [Link] method. must also implement the
5. return [Link]([Link]); cannot be accessed in line 5. method in line 4 will
hashCode method.
6. } prevent duplicates.
7. }
</pre>
Which Statement is True?
A
<pre>
1. public class Person {
2. private String name, comment;
3. private int age;
4. public Person(String n, int a, String
c) {
5. name = n; age = a; comment = c;
6. }
7. public boolean equals(Object o) { return [Link]()
return [Link]() + age return [Link]() +
8. if (! (o instanceof Person)) return return [Link](); + [Link]() /
* 7; [Link]() / 2;
false; 2 ‐ age * 3;
9, Person p = (Person)o;
10. return age == [Link] &&
[Link]([Link]);
11. }
12. }
</pre> What is the appropriate
definition of the hashCode method in
class Person?
B
<pre>
1. HashMap props = new HashMap();
2. [Link]("key45", "some value");
3. [Link]("key12", "some other
value");
4. [Link]("key39", "yet another
[Link](s); s = new TreeSet(s); [Link](s); s = new SortedSet(s);
value");
5. Set s = [Link]();
6. // insert code here
</pre>
What, inserted at line 6, will sort the
keys in the props HashMap?
B