You are on page 1of 8

[1] Which of these packages contain all the collection classes?

a) java.lang
b) java.util
c) java.net
d) java.awt
Answer: b
[2] Which of these classes is not part of Java’s collection framework?
a) Maps
b) Array
c) Stack
d) Queue
Answer: a
[3] which of these interface is not a part of Java’s collection framework?
a) List
b) Set
c) SortedMap
d) SortedList
Answer: d
Explanation: SortedList is not a part of collection framework.
[4] Which of these methods deletes all the elements from invoking collection?
a) clear()
b) reset()
c) delete()
d) refresh()
Answer: a
Explanation: clear() method removes all the elements from invoking collection.
[5] What is Collection in Java?
a) A group of objects
b) A group of classes
c) A group of interfaces
d) None of the mentioned
Answer: a
[6] What is the output of this program?

import java.util.*;
class Array
{
public static void main(String args[])
{
int array[] = new int [5];
for (int i = 5; i > 0; i--)
array[5-i] = i;
Arrays.fill(array, 1, 4, 8);
for (int i = 0; i < 5 ; i++)
System.out.print(array[i]);
}
}
12885
12845
58881
54881
View Answer

Answer: c
[7] Which of these is necessary condition for automatic type conversion in Java?
a) The destination type is smaller than source type
b) The destination type is larger than source type
c) The destination type can be larger or smaller than source type
d) None of the mentioned
View Answer

Answer: b
[8] Which of these is supported by method overriding in Java?
a) Abstraction
b) Encapsulation
c) Polymorphism
d) None of the mentioned
View Answer

Answer: c
[9] What is the output of this program?

final class A
{
int i;
}
class B extends A
{
int j;
System.out.println(j + " " + i);
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.display();
}
}
22
33
Runtime Error
Compilation Error
View Answer

Answer: d
[10] What is the output of this program?

import java.util.*;
class stack
{
public static void main(String args[])
{
Stack obj = new Stack();
obj.push(new Integer(3));
obj.push(new Integer(2));
obj.pop();
obj.push(new Integer(5));
System.out.println(obj);
}
}
[3, 5].
[3, 2].
[3, 2, 5].
[3, 5, 2].
View Answer

Answer: a
[11] What is multithreaded programming?
a) It’s a process in which two different processes run simultaneously
b) It’s a process in which two or more parts of same process run simultaneously
c) It’s a process in which many different process are able to access same information
d) It’s a process in which a single process can access information from many sources
View Answer

Answer: b
Explanation: Multithreaded programming a process in which two or more parts of same
process run simultaneously.
[12] 2. Which of these are types of multitasking?
a) Process based
b) Thread based
c) Process and Thread based
d) None of the mentioned
View Answer

Answer: c
Explanation: There are two types of multitasking: Process based multitasking and Thread based
multitasking.
[13] Which of these packages contain all the Java’s built in exceptions?
a) java.io
b) java.util
c) java.lang
d) java.net
View Answer

Answer: c
Explanation: None.
[14] What is the process of defining more than one method in a class differentiated by
parameters?
a) Function overriding
b) Function overloading
c) Function doubling
d) None of the mentioned
View Answer

Answer:b

[15] public class While


{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x + 1)); /* Line 8 */
}
}
}
Which statement is true?
There is a syntax error on line 1.
There are syntax errors on lines 1 and 6.
There are syntax errors on lines 1, 6, and 8.
There is a syntax error on line 6.
Answer: Option D

[16] What is the output of this program?

class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}
02468
13579
0123456789
1 2 3 4 5 6 7 8 9 10

Answer: a
[17] Which keyword is used by method to refer to the object that invoked it?
a) import
b) catch
c) abstract
d) this
View Answer
Answer: d

[18] All the variables of interface should be ?


a) default and final
b) default and static
c) public,static
d) protect, static and final

Answer: c
[19] What is true of final class?
a) Final class cause compilation failure
b) Final class cannot be instantiated
c) Final class cause runtime failure
d) Final class cannot be inherited
View Answer

Answer: d
[20] Which of these class can generate an array which can increase and decrease in
size automatically?
a) ArrayList()
b) DynamicList()
c) LinkedList()
d) MallocList()
View Answer

Answer: a
[21] What is the output of this program?
class A
{
int i;
void display()
{
System.out.println(i);
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a) 0
b) 1
c) 2
d) Compilation Error
View Answer

Answer: c
[22] Which concept of Java is achieved by combining methods and attribute into a
class?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
View Answer

Answer: a
[23] What is the extension of compiled java classes?
a) .class
b) .java
c) .txt
d) .js
View Answer

Answer: a
[24] Which of these keywords is used to prevent content of a variable from being
modified?
a) final
b) last
c) constant
d) static
View Answer

Answer: a
[25] Which of these cannot be declared static?
a) class
b) object
c) variable
d) method
View Answer

Answer: b
[26] What is the output of this program?

class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.print(y);
}
}
a) 12
b) 200
c) 400
d) 100
View Answer
Answer: b
[27] Which of these keywords is used to refer to member of base class from a
subclass?
a) upper
b) super
c) this
d) none of the mentioned
View Answer

Answer: b
Explanation: Whenever a subclass needs to refer to its immediate superclass, it can do so by use
of the keyword super.
[28] A class member declared protected becomes member of subclass of which type?
a) public member
b) private member
c) protected member
d) static member
View Answer

Answer: b
[29] Explanation: A class member declared protected becomes private member of
subclass.
4. Which of these is correct way of inheriting class A by class B?
a) class B + class A {}
b) class B inherits class A {}
c) class B extends A {}
d) class B extends class A {}
View Answer

Answer: c
Explanation: None.
[30] Which component is responsible to optimize bytecode to machine code?
a) JVM
b) JDK
c) JIT
d) JRE
View Answer

Answer: c

You might also like