Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  Which of these classes is not part of Java's collection framework?

a. Maps

b. Array

c. Stack

d. Queue


Answer- Maps


Que-  Which of this interface is not a part of Java's collection framework?

a. List

b. Set

c. SortedMap

d. SortedList


Answer- SortedList


Que-  Which of these methods deletes all the elements from invoking collection?

a. clear()

b. reset()

c. delete()

d. refresh()


Answer- clear()


Que-  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 group of objects


Que-  Which of these return type of hasNext() method of an iterator?

a. Integer

b. Double

c. Boolean

d. Collections Object


Answer- Boolean


Que-  Which of these methods is used to obtain an iterator to the start of collection?

a. start()

b. begin()

c. iteratorSet()

d. iterator()


Answer- iterator()


Que-  Which of these methods can be used to move to next element in a collection?

a. next()

b. move()

c. shuffle()

d. hasNext()


Answer- next()


Que-  Which of these iterators can be used only with List?

a. Setiterator

b. ListIterator

c. Literator

d. None of the mentioned


Answer- ListIterator


Que-  Which of these is a method of ListIterator used to obtain index of previous element?

a. previous()

b. previousIndex()

c. back()

d. goBack()


Answer- previousIndex()


Que-  Which of these exceptions is thrown by remover() method?

a. IOException

b. SystemException

c. ObjectNotFoundExeception

d. IllegalStateException


Answer- IllegalStateException


Que-  Which of the below is not a subinterface of Queue?

a. BlockingQueue

b. BlockingEnque

c. TransferQueue

d. BlockingQueue


Answer- BlockingEnque


Que-  What is the remaining capacity of BlockingQueue whose intrinsic capacity is not defined?

a. Integer.MAX_VALUE

b. BigDecimal.MAX_VALUE

c.99999999

d. Integer.INFINITY


Answer- Integer.MAX_VALUE


Que-  PriorityQueue is thread safe.

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  What is difference between dequeue() and peek() function of java?

a. dequeue() and peek() remove and return the next time in line

b. dequeue() and peek() return the next item in line

c. dequeue() removes and returns the next item in line while peek() returns the next item in line

d. peek() removes and returns the next item in line while dequeue() returns the next item in line


Answer- dequeue() removes and returns the next item in line while peek() returns the next item in line


Que-  What is the difference between Queue and Stack?

a. Stack is LIFO; Queue is FIFO

b. Queue is LIFO; Stack is FIFO

c. Stack and Queue is FIFO

d. Stack and Queue is LIFO


Answer- Stack is LIFO; Queue is FIFO


Que-  What are the use of front and rear pointers in CircularQueue implementation?

a. Front pointer points to first element; rear pointer points to the last element

b. Rear pointer points to first element; front pointer points to the last element

c. Front and read pointers point to the first element

d. Front pointer points to the first element; rear pointer points to null object


Answer- Front and read pointers point to the first element


Que-  What is the correct method used to insert and delete items from the queue?

a. push and pop

b. enqueue and dequeue

c. enqueue and peek

d. add and remove


Answer- enqueue and dequeue


Que-  Which data structure is used in Breadth First Traversal of a graph?

a. Stack

b. Queue

c. Array

d. Tree


Answer- Queue


Que-  Where does a new element be inserted in linked list implementation of a queue?

a. Head of list

b. Tail of list

c. At the centre of list

d. All the old entries are pushed and then the new element is inserted


Answer- Tail of list


Que-  If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?

a. rear=(rear%1)+MAX_SIZE

b. rear=(rear+1)%MAX_SIZE

c. rear=rear+(1%MAX_SIZE)

d. rear=rear%(MAX_SIZE+1)


Answer- rear=(rear+1)%MAX_SIZE


Que-  Which of these standard collection classes implements all the standard functions on list data structure?

a. Array

b. LinkedList

c. HashSet

d. AbstractSet


Answer- Array


Que-  Which of this method is used to make all elements of an equal to specified value?

a. add()

b. fill()

c. all()

d. set()


Answer- fill()


Que-  Which of these method of Array class is used sort an array or its subset?

a. binarysort()

b. bubblesort()

c. sort()

d. insert()


Answer- sort()


Que-  Which of these methods can be used to search an element in a list?

a. find()

b. sort()

c. get()

d. binaryserach()


Answer- binaryserach()


Que-  Which of these interface declares core method that all collections will have?

a. set

b. EventListner

c. Comparator

d. Collection


Answer- Collection


Que-  Which of these interface handle sequences?

a. Set

b. List

c. Comparator

d. Collection


Answer- List


Que-  Which of this interface must contain a unique element?

a. Set

b. List

c. Array

d. Collection


Answer- Set


Que-  Which of these is a Basic interface that all other interface inherits?

a. Set

b. Array

c. List

d. Collection


Answer- Collection


Que-  Which of these is static variable defined in Collections?

a. EMPTY_SET

b. EMPTY_LIST

c. EMPTY_MAP

d. All of the mentioned


Answer- All of the mentioned


Que-  Which of these is an incorrect form of using method max() to obtain a maximum element?

a. max(Collection c)

b. max(Collection c, Comparator comp)

c. max(Comparator comp)

d. max(List c)


Answer- max(Comparator comp)

Previous Post Next Post