0% found this document useful (0 votes)
44 views4 pages

Core Java Mock 2 Cdac Met

Uploaded by

White Devil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views4 pages

Core Java Mock 2 Cdac Met

Uploaded by

White Devil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Correct

Q. No. Topic Question Option1 Option2 Option3 Option4


Option
Under JVM, _______ handles translation of byte-code
1 CJMock System Class Loader Hot-Spot Engine Runtime Library None of the above Option2
into machine instructions.
Apart from java.lang.Object, every class in Java
2 CJMock atleast atmost exactly All of the above Option3
inherits from _______ one class
A protected member declared in a class is any subclass or a class in the class in the current
3 CJMock subclass None of the above Option1
accessible to any _______. current package. package
Given threads t1 and t2. In its run method t1
4 CJMock t1 t2 main All of the above Option1
executes t2.join(),_______ thread will be blocked.
5 CJMock The filter method of stream API is ________ operation. an initial a terminal an intermediate All of the above Option3

6 CJMock Random access in _______ has a complexity of O(n). java.util.ArrayList java.util.LinkedList java.util.HashSet None of the above Option2

94
The wait and notify methods are members of
7 CJMock java.lang.Object java.lang.Thread java.lang.Monitor All of the above Option1
_________

21
A non-static field declared with _______ modifier is
8 CJMock private protected transient None of the above Option3
not serialized.
Annotation with _______ retention policy is discarded

59
9 CJMock SOURCE CLASS RUNTIME All of the above Option1
by the compiler.
The for-each loop syntax requires the source object

07
10 CJMock java.util.Iterable java.lang.Iterable java.util.Iterator All of the above Option2
to implement ________.
11 CJMock Following is true about Abstract class Static inner class Visible outside of its package Friend class Cannot be instantiated Option4

80
12 CJMock Following is true aboutFinal class Static inner class Visible outside of its package Friend class Cannot be extended Option4
13 CJMock Following is true about Public class Static inner class Visible outside of its package Friend class Cannot be extended Option2

.in
14 CJMock Following is true about Nested class Static inner class Visible outside of its package Friend class Cannot be extended Option1
15 CJMock Following is true about Anonymous class Static inner class Exactly one instance Friend class Cannot be extended Option2

ys
Public members of a non-public class are not
16 CJMock TRUE FALSE NA NA Option1
accessible outside its package.

ra
URLClassLoader is the parent of system class-
17 CJMock TRUE FALSE NA NA Option2
loader.
18 CJMock
Static member fields of a class are included in the
serialization process. ar TRUE FALSE NA NA Option2
ith
The default security-manager does not allow
19 CJMock TRUE FALSE NA NA Option1
creation of class-loader.
w

The start method of Thread can be used to restart a


20 CJMock TRUE FALSE NA NA Option2
stopped thread.
de

An interface cannot inherit from multiple


21 CJMock TRUE FALSE NA NA Option2
interfaces.
co

An inner non-static member class cannot have


22 CJMock TRUE FALSE NA NA Option1
static members.
A thread can acquire monitors of more than one
23 CJMock TRUE FALSE NA NA Option1
object.
Correct
Q. No. Topic Question Option1 Option2 Option3 Option4
Option
Object of a subclass of a serializable class is
24 CJMock TRUE FALSE NA NA Option1
automatically serializable.
In Java generics, a type parameter can be
25 CJMock TRUE FALSE NA NA Option2
instantiated with new operator
Under Java, an organization of related classes is
26 CJMock Package namespace Assembly None of the above Option1
called a _______.
All the fields of an interface are public static and
27 CJMock transient final None Both of the above Option2
_____ by default.
The java.lang. _____ class boxes a value of primitive
28 CJMock Character Char Object None of the above Option1
type char in an object.
The ____ keyword is used for making a block of code
29 CJMock sync synchronized using None of the above Option2
thread-safe.

94
A class must implement ____ interface for java.lang.Object.Serializ java.io.Externalizabl
30 CJMock java.io.Enumerable None of the above Option3
custimizing serialization of its objects. able e

21
31 CJMock Final key word can be applied to Class Field method All of the above Option4
To apply static binding on methods use ________
32 CJMock Final virtual static None of the above Option1
modifier to methods

59
33 CJMock To check object identity we can use ________ = instanceof === None of the above Option1
Finalize, Final, Finally, out of this following is used

07
34 CJMock Finally Final Finalize None of the above Option1
in exception handling
35 CJMock Checked Exception are checked at _________ Compile time Runtime Both None of the above Option1

80
36 CJMock Checked Exceptions are inherited from Exception Throwable RuntimeException None of the above Option1
Object has to
If an object need to release its resource You have call finalize on

.in
37 CJMock You have to call close on object implement All of the above Option3
automatically, then ________ object
Autocloseable

ys
Interfaces which
Interfaces which have have only one
Interfaces which have only one

ra
38 CJMock Functional Interfaces are _______ only one abstract implemented None of the above Option1
implementedmethod
method method and one

To create thread , Thread constructor has to be


ar
Object of class which
abstract method
Annonymous which
ith
39 CJMock Lamda Expression implements All of the above Option4
passed implements Runnable
Runnable
w

40 CJMock Wait, notify are method of Thread Class Object Runnable Interface None of the above Option2
Which of these packages contain all the collection
de

41 CJMock java.lang java.util java.net java.awt Option2


classes?
Which of these classes is not part of Java’s
co

42 CJMock Maps Array Stack Queue Option1


collection framework?
Which of these methods deletes all the elements
43 CJMock clear() reset() delete() refresh() Option1
from invoking collection?
Which of these return type of hasNext() method of
44 CJMock Integer Double Boolean Collections Object Option3
an iterator?
Which of these methods is used to obtain an
45 CJMock start() begin() iteratorSet() iterator() Option4
iterator to the start of collection?
Correct
Q. No. Topic Question Option1 Option2 Option3 Option4
Option
What will be the output of the following Java
program?

import java.util.*;
class Collection_iterators
{
public static void main(String args[])
{
LinkedList list = new LinkedList();
list.add(new Integer(2));
46 CJMock 2851 1582 2 2185 Option2
list.add(new Integer(8));
list.add(new Integer(5));

94
list.add(new Integer(1));
Iterator i = list.iterator();

21
Collections.reverse(list);
while(i.hasNext())
System.out.print(i.next() + " ");

59
}
}

07
dequeue() removes peek() removes and

80
and returns the returns the next item in
dequeue() and peek()
What is difference between dequeue() and peek() dequeue() and peek() return the next item in line line while dequeue()
47 CJMock remove and return the Option3
function of java? next item in line while peek() returns the next item in

.in
next time in line
returns the next line
item in line

ys
Front pointer points to Front pointer points to
Rear pointer points to first Front and read
What are the use of front and rear pointers in first element; rear the first element; rear
48 CJMock element; front pointer points to pointers point to Option3

ra
CircularQueue implementation? pointer points to the pointer points to null
the last element the first element
last element object
49 CJMock
Which of these method of Array class is used sort
an array or its subset? ar binarysort() bubblesort() sort() insert() Option3
ith
Which of this interface must contain a unique
50 CJMock Set List Array Collection Option1
element?
w

Optional type
de

declaration - No need to Optional parenthesis around


declare the type of a parameter - No need to declare a
Which of the following is correct about Java 8 Both of the above. None of the above.
co

51 CJMock parameter. The single parameter in parenthesis. Option3


lambda expression?
compiler can inference For multiple parameters,
the same from the value parentheses are required.
of the parameter.
It can implement
It can extend exactly It can extend
multiple interfaces
one class and It can extend exactly one class and exactly one class or
52 CJMock Which is true about an anonymous inner class? regardless of whether it Option3
implement exactly one can implement multiple interfaces. implement exactly
also extends a class.
interface. one interface.
Answer: Option C
Correct
Q. No. Topic Question Option1 Option2 Option3 Option4
Option
You must have a
It does not have access to It's variables and
reference to an instance It must extend the
53 CJMock Which statement is true about a static nested class? nonstatic members of the methods must be Option2
of the enclosing class in enclosing class.
enclosing class. static.
order to instantiate it.
public class MyOuter
{
public static class MyInner MyOuter m = new
{ MyOuter.MyInner m = MyOuter();
MyInner mi = new
public static void foo() { } new MyOuter.MyInner mi = new
54 CJMock MyOuter.MyInner(); Option1
} MyOuter.MyInner(); MyInner(); MyOuter.MyInner
} mi = m.new

94
which statement, if placed in a class other than MyOuter.MyInner();
MyOuter or MyInner, instantiates an instance of the

21
nested class?
private static void payAnnualInterest(Account[]
accounts){

59
for(Account acc : accounts){ instanceof operator
if(acc instanceof Profitable){ checks whether acc is instanceof operator checks

07
instanceof is a
55 CJMock Profitable p = (Profitable)acc; instance of Profitable whether acc is instance of All of the above Option1
function
p.addInterest(12); but does not do Profitable and does conversion

80
} conversion
}
}

.in
In Java, the == operator
Identical Objects
Following is true about == Operator and equals() compares that two equals() method compares two
56 CJMock are also by default all of the above Option4

ys
Method references are identical objects.
equal.
or not.

ra
It is not necessary
that if the two
arWhen it is invoked
objects are unequal
ith
according to
more than once during
equals() method,
the execution of an
w

If the two objects are equal then invoking the


application, the
according to the equals() method, hashCode() method
de

Following is true related to hasCode() method hashCode() method will


57 CJMock then invoking the hashCode() on these two All of the above Option4
he general contract for hashCode is: consistently return the
method on these two objects must objects may
same hash code
co

produce the same integer value. produce distinct


(integer value). Note
integer value. It
that the object should
means that it can
not be modified.
produce the same
hash code for both
objects.
58 CJMock Following is not a method of Object Class hashCode() toString() equals() join() Option4
IndexOutOfBoundsExce
ClassNotFoundExce
59 CJMock Which one is not a checked Exceptions IOException SQLException ption Option4
ption
IF you want to create a checked Exception create a
60 CJMock Exception Error RunTimeException None of the above Option1
new class which extends

You might also like