Explore topic-wise MCQs in Technical Programming.

This section includes 1671 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

851.

Which of these keywords is used to manually throw an exception?

A. try
B. finally
C. finally
D. catch
Answer» D. catch
852.

Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

A. try
B. finally
C. throw
D. catch
Answer» E.
853.

Which of these keywords is not a part of exception handling?

A. try
B. finally
C. thrown
D. catch
Answer» D. catch
854.

When does Exceptions in Java arises in code sequence?

A. Run Time
B. Compilation Time
C. Can Occur Any Time
D. None of the mentioned
Answer» B. Compilation Time
855.

What is the output of this program? import java.util.*; class Collection_Algos { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); Collections.shuffle(list); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 1 2 5 8
D. Any random order
Answer» E.
856.

What is the output of this program? import java.util.*; class Collection_Algos { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); Collections.sort(list); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 1 2 5 8
D. 2 1 8 5
Answer» D. 2 1 8 5
857.

What is the output of this program? import java.util.*; class Collection_Algos { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 2
D. 2 1 8 5
Answer» C. 2
858.

What is the output of this program? import java.util.*; class Collection_Algos { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 2
D. 2 1 8 5
Answer» B. 1 5 8 2
859.

Which of these is static variable defined in Collections?

A. EMPTY_SET
B. EMPTY_LIST
C. EMPTY_MAP
D. All of the mentioned
Answer» E.
860.

Which of these is true about unmodifiableCollection() method?

A. unmodifiableCollection() returns a collection that cannot be modified
B. unmodifiableCollection() method is available only for List and Set
C. unmodifiableCollection() is defined in Collection class
D. none of the mentioned
Answer» C. unmodifiableCollection() is defined in Collection class
861.

Which of these methods can convert an object into a List?

A. SetList()
B. ConvertList()
C. singletonList()
D. CopyList()
Answer» D. CopyList()
862.

Which of these methods can randomize all elements in a list?

A. rand()
B. randomize()
C. shuffle()
D. ambiguous()
Answer» D. ambiguous()
863.

Which of these methods sets every element of a List to a specified object?

A. set()
B. fill()
C. Complete()
D. add()
Answer» C. Complete()
864.

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

A. max(Collection c)
B. max(Collection c, Comparator comp)
C. max(Comparator comp)
D. max(List c)
Answer» D. max(List c)
865.

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.sort(array); for (int i = 0; i < 5; ++i) System.out.print(array[i]);; } }

A. 12345
B. 54321
C. 1234
D. 5432
Answer» B. 54321
866.

Which of these is Basic interface that all other interface inherits?vv

A. Set
B. Array
C. List
D. Collection
Answer» E.
867.

Which of these interface must contain a unique element?

A. Set
B. List
C. Array
D. Collection
Answer» B. List
868.

Which of these interface handle sequences?

A. Set
B. List
C. Comparator
D. Collection
Answer» C. Comparator
869.

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

A. set
B. EventListner
C. Comparator
D. Collection
Answer» E.
870.

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.sort(array); System.out.print(Arrays.binarySearch(array, 4)); } }

A. 2
B. 3
C. 4
D. 5
Answer» C. 4
871.

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.sort(array); for (int i = 0; i < 5; ++i) System.out.print(array[i]);; } }

A. 12345
B. 54321
C. 1234
D. 5432
Answer» B. 54321
872.

What is the output of this program? import java.util.*; class Arraylist { public static void main(String args[]) { ArrayList obj1 = new ArrayList(); ArrayList obj2 = new ArrayList(); obj1.add("A"); obj1.add("B"); obj2.add("A"); obj2.add(1, "B"); System.out.println(obj1.equals(obj2)); } }

A. 0
B. 1
C. True
D. False
Answer» D. False
873.

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

A. find()
B. sort()
C. get()
D. binaryserach()
Answer» E.
874.

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

A. binarysort()
B. bubblesort()
C. sort()
D. insert()
Answer» D. insert()
875.

Which of these method is used to make all elements of an equal to specified value?

A. add()
B. fill()
C. all()
D. set()
Answer» C. all()
876.

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

A. Array
B. LinkedList
C. HashSet
D. AbstractSet
Answer» B. LinkedList
877.

If the size of the array used to implement 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» C. rear=rear+(1%MAX_SIZE)
878.

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» C. At the centre of list
879.

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

A. Stack
B. Queue
C. Array
D. Tree
Answer» C. Array
880.

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

A. push and pop
B. enqueue and dequeue
C. enqueue and peek
D. add and remove
Answer» C. enqueue and peek
881.

What is 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» D. Front pointer points to the first element; rear pointer points to null object
882.

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» B. Queue is LIFO; Stack is FIFO
883.

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» D. peek() removes and returns the next item in line while dequeue() returns the next item in line
884.

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» B. BigDecimal.MAX_VALUE
885.

Which of the below is not a subinterface of Queue?

A. BlockingQueue
B. BlockingEnque
C. TransferQueue
D. BlockingQueue
Answer» C. TransferQueue
886.

What is the output of this program? import java.util.*; class Collection_iterators { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); Collections.shuffle(list); i.next(); i.remove(); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5
B. 2 1 8
C. 2 5 8
D. 8 5 1
Answer» C. 2 5 8
887.

What is the output of this program? import java.util.*; class Collection_iterators { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); Collections.sort(list); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 1 2 5 8
D. 2 1 8 5
Answer» D. 2 1 8 5
888.

What is the output of this program? import java.util.*; class Collection_iterators { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); while(i.hasNext()) System.out.print(i.next() + " "); } }

A. 2 8 5 1
B. 1 5 8 2
C. 2
D. 2 1 8 5
Answer» C. 2
889.

What is the output of this program? import java.util.*; class Collection_iterators { public static void main(String args[]) { ListIterator a = list.listIterator(); if(a.previousIndex()! = -1) while(a.hasNext()) System.out.print(a.next() + " "); else System.out.print("EMPTY"); } }

A. 0
B. 1
C. -1
D. EMPTY
Answer» E.
890.

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

A. IOException
B. SystemException
C. ObjectNotFoundExeception
D. IllegalStateException
Answer» E.
891.

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

A. previous()
B. previousIndex()
C. back()
D. goBack()
Answer» C. back()
892.

Which of these iterators can be used only with List?

A. Setiterator
B. ListIterator
C. Literator
D. None of the mentioned
Answer» C. Literator
893.

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

A. next()
B. move()
C. shuffle()
D. hasNext()
Answer» B. move()
894.

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

A. start()
B. begin()
C. iteratorSet()
D. iterator()
Answer» E.
895.

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

A. Integer
B. Double
C. Boolean
D. Collections Object
Answer» D. Collections Object
896.

What is the output of this program? import java.util.*; class Bitset { public static void main(String args[]) { BitSet obj = new BitSet(5); for (int i = 0; i < 5; ++i) obj.set(i); obj.clear(2); System.out.print(obj); } }

A. {0, 1, 3, 4}
B. {0, 1, 2, 4}
C. {0, 1, 2, 3, 4}
D. {0, 0, 0, 3, 4}
Answer» B. {0, 1, 2, 4}
897.

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]); } }

A. 12885
B. 12845
C. 58881
D. 54881
Answer» D. 54881
898.

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

A. clear()
B. reset()
C. delete()
D. refresh()
Answer» B. reset()
899.

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

A. Maps
B. Array
C. Stack
D. Queue
Answer» B. Array
900.

What is the output of this program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Method methods[] = c.getMethods(); for (int i = 0; i < methods.length; i++) System.out.println(methods[i]); } catch (Exception e) { System.out.print("Exception"); } } }

A. Program prints all the constructors of ‘java.awt.Dimension’ package
B. Program prints all the methods of ‘java.awt.Dimension’ package
C. Program prints all the data members of ‘java.awt.Dimension’ package
D. program prints all the methods and data member of ‘java.awt.Dimension’ package
Answer» C. Program prints all the data members of ‘java.awt.Dimension’ package