0% found this document useful (0 votes)
260 views

Java MCQ-5

This document contains 30 multiple choice questions about Java programming concepts like collections, inheritance, polymorphism, multithreading, and more. It appears to be from an open course on day 5 that covers Java fundamentals and the collection framework.

Uploaded by

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

Java MCQ-5

This document contains 30 multiple choice questions about Java programming concepts like collections, inheritance, polymorphism, multithreading, and more. It appears to be from an open course on day 5 that covers Java fundamentals and the collection framework.

Uploaded by

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

BMS INSTITUTE OF TECHNOLOGY AND MANAGEMENT

YELAHANKA – BANGALORE - 64
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Open Course- DAY 5

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


a) java.lang b) java.util c)java.net d)java.awt

[2] Which of these classes is not part of Java’s collection framework?


a) Maps b)Array c)Stack d)Queue

[3] which of these interface is not a part of Java’s collection framework?


a) List b)Set c)SortedMap d)SortedList

[4] Which of these methods deletes all the elements from invoking collection?
a) clear() b)reset() c)delete() d)refresh()

[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

[6] Which of these class is used to make a thread?


a) String b) System c) Thread d) Runnable

[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

[8] Which of these is supported by method overriding in Java?


a) Abstraction b)Encapsulation c)Polymorphism d)None of the mentioned

[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();
}
}
a) 2 2 b)3 3 c)Runtime Error d) Compilation Error
[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);
}
}
a) [3, 5]. B)[3, 2]. C)[3, 2, 5]. D)[3, 5, 2].

[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

[12] Which of these are types of multitasking?


a) Process based b)Thread based
c) Process and Thread based d)None of the mentioned
.
[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

[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

[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?
a) There is a syntax error on line 1. B)There are syntax errors on lines 1 and 6.
c)There are syntax errors on lines 1, 6, and 8. D) There is a syntax error on line 6.
[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++;
}} }
a) 0 2 4 6 8 b)1 3 5 7 9 c)0 1 2 3 4 5 6 7 8 9 d)1 2 3 4 5 6 7 8 9 10

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

[18] All the variables of interface should be ?


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

[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

[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()

[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

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

[23] What is the extension of compiled java classes?


a) .class b) .java c) .txt d) .js

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

[25] Which of these cannot be declared static?


a) class b) object c) variable d) method

[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

[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

[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

[29] 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 {}

[30] Which component is responsible to optimize bytecode to machine code?


a) JVM b) JDK c) JIT d) JRE

You might also like