MCQOPTIONS
Saved Bookmarks
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.
| 901. |
What is the length of the application box made by this program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet",20,20); } |
| A. | 20 |
| B. | Default value |
| C. | Compilation Error |
| D. | Runtime Error |
| Answer» D. Runtime Error | |
| 902. |
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"); Constructor constructors[] = c.getConstructors(); for (int i = 0; i < constructors.length; i++) System.out.println(constructors[i]); } catch (Exception e) { System.out.print("Exception"); } } } |
| A. | Program prints all the constructors of ‘java.awt.Dimension’ package |
| B. | Program prints all the possible constructors of class ‘Class’ |
| C. | Program prints “Exception” |
| D. | Runtime Error |
| Answer» B. Program prints all the possible constructors of class ‘Class’ | |
| 903. |
Which of these package is used for all the text related modifications? |
| A. | java.text |
| B. | java.awt |
| C. | java.lang.text |
| D. | java.lang.text |
| Answer» B. java.awt | |
| 904. |
Which of these class is used for creating a client for a server-client operations? |
| A. | serverClientjava |
| B. | Client.java |
| C. | AddClient.java |
| D. | ServerClient.java |
| Answer» D. ServerClient.java | |
| 905. |
Which of these Exceptions is thrown by remote method? |
| A. | RemoteException |
| B. | InputOutputException |
| C. | RemoteAccessException |
| D. | RemoteInputOutputException |
| Answer» B. InputOutputException | |
| 906. |
Which of these methods are member of Remote class? |
| A. | checkIP() |
| B. | addLocation() |
| C. | AddServer() |
| D. | None of the mentioned |
| Answer» E. | |
| 907. |
Which of these package is used for remote method invocation? |
| A. | java.applet |
| B. | java.rmi |
| C. | java.lang.rmi |
| D. | java.lang.reflect |
| Answer» C. java.lang.rmi | |
| 908. |
What is Remote method invocation (RMI)? |
| A. | RMI allows us to invoke a method of java object that executes on another machine |
| B. | RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming |
| C. | RMI allows us to invoke a method of java object that executes parallely in same machine |
| D. | None of the mentioned |
| Answer» B. RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming | |
| 909. |
What is the output of this program? import java.util.*; class Bitset { public static void main(String args[]) { BitSet obj1 = new BitSet(5); BitSet obj2 = new BitSet(10); for (int i = 0; i < 5; ++i) obj1.set(i); for (int i = 3; i < 13; ++i) obj2.set(i); obj1.and(obj2); System.out.print(obj1); } } |
| A. | {0, 1} |
| B. | {2, 4} |
| C. | {3, 4} |
| D. | {3, 4, 5} |
| Answer» D. {3, 4, 5} | |
| 910. |
What is the output of this program? import java.util.*; class date { public static void main(String args[]) { Date obj = new Date(); System.out.print(obj); } } |
| A. | Prints Present Date |
| B. | Runtime Error |
| C. | Any Garbage Value |
| D. | Prints Present Time & Date |
| Answer» E. | |
| 911. |
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); System.out.print(obj.get(3)); } } |
| A. | 2 |
| B. | 3 |
| C. | 4 |
| D. | 5 |
| Answer» B. 3 | |
| 912. |
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.length() + " " + obj.size()); } } |
| A. | 4 64 |
| B. | 5 64 |
| C. | 5 128 |
| D. | 4 128 |
| Answer» C. 5 128 | |
| 913. |
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} | |
| 914. |
Which of these methods is used to retrieve elements in BitSet object at specific location? |
| A. | get() |
| B. | Elementat() |
| C. | ElementAt() |
| D. | getProperty() |
| Answer» B. Elementat() | |
| 915. |
Which of these is a method of class Date which is used to search whether object contains a date before the specified date? |
| A. | after() |
| B. | contains() |
| C. | before() |
| D. | compareTo() |
| Answer» D. compareTo() | |
| 916. |
Which of these method is used to calculate number of bits required to hold the BitSet object? |
| A. | size() |
| B. | length() |
| C. | indexes() |
| D. | numberofBits() |
| Answer» C. indexes() | |
| 917. |
Which of these method is used to make a bit zero specified by the index? |
| A. | put() |
| B. | set() |
| C. | remove() |
| D. | clear() |
| Answer» E. | |
| 918. |
Which of these class object has architecture similar to that of array? |
| A. | Bitset |
| B. | Map |
| C. | Hashtable |
| D. | All of the mentioned |
| Answer» B. Map | |
| 919. |
What is the output of this program? import java.util.*; class properties { public static void main(String args[]) { Properties obj = new Properties(); obj.put("AB", new Integer(3)); obj.put("BC", new Integer(2)); obj.put("CD", new Integer(8)); System.out.print(obj.keySet()); } } |
| A. | {AB, BC, CD} |
| B. | [AB, BC, CD]. |
| C. | [3, 2, 8]. |
| D. | {3, 2, 8} |
| Answer» C. [3, 2, 8]. | |
| 920. |
What is the output of this program? import java.util.*; class hashtable { public static void main(String args[]) { Hashtable obj = new Hashtable(); obj.put("A", new Integer(3)); obj.put("B", new Integer(2)); obj.put("C", new Integer(8)); System.out.print(obj.toString()); } } |
| A. | {C=8, B=2} |
| B. | [C=8, B=2] |
| C. | {A=3, C=8, B=2} |
| D. | [A=3, C=8, B=2]. |
| Answer» D. [A=3, C=8, B=2]. | |
| 921. |
What is the output of this program? import java.util.*; class hashtable { public static void main(String args[]) { Hashtable obj = new Hashtable(); obj.put("A", new Integer(3)); obj.put("B", new Integer(2)); obj.put("C", new Integer(8)); obj.remove(new String("A")); System.out.print(obj); } } |
| A. | {C=8, B=2} |
| B. | [C=8, B=2]. |
| C. | {A=3, C=8, B=2} |
| D. | [A=3, C=8, B=2]. |
| Answer» B. [C=8, B=2]. | |
| 922. |
What is the output of this program? import java.util.*; class hashtable { public static void main(String args[]) { Hashtable obj = new Hashtable(); obj.put("A", new Integer(3)); obj.put("B", new Integer(2)); obj.put("C", new Integer(8)); obj.clear(); System.out.print(obj.size()); } } |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 3 |
| Answer» B. 1 | |
| 923. |
What is the output of this program? import java.util.*; class hashtable { public static void main(String args[]) { Hashtable obj = new Hashtable(); obj.put("A", new Integer(3)); obj.put("B", new Integer(2)); obj.put("C", new Integer(8)); System.out.print(obj.contains(new Integer(5))); } } |
| A. | 0 |
| B. | 1 |
| C. | True |
| D. | False |
| Answer» E. | |
| 924. |
Which of these methods is used to retrieve the elements in properties object at specific location? |
| A. | get() |
| B. | Elementat() |
| C. | ElementAt() |
| D. | getProperty() |
| Answer» E. | |
| 925. |
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes? |
| A. | Map |
| B. | Enumeration |
| C. | HashMap |
| D. | Hashtable |
| Answer» B. Enumeration | |
| 926. |
Which of these method is used to insert value and its key? |
| A. | put() |
| B. | set() |
| C. | insertElement() |
| D. | addElement() |
| Answer» B. set() | |
| 927. |
Which of these class object uses key to store value? |
| A. | Dictionary |
| B. | Map |
| C. | Hashtable |
| D. | All of the mentioned |
| Answer» E. | |
| 928. |
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]. |
| Answer» B. [3, 2]. | |
| 929. |
What is the output of this program? import java.util.*; class vector { public static void main(String args[]) { Vector obj = new Vector(4,2); obj.addElement(new Integer(3)); obj.addElement(new Integer(2)); obj.addElement(new Integer(5)); obj.removeAll(obj); System.out.println(obj.isEmpty()); } } |
| A. | 0 |
| B. | 1 |
| C. | True |
| D. | False |
| Answer» D. False | |
| 930. |
. What is the output of this program? import java.util.*; class vector { public static void main(String args[]) { Vector obj = new Vector(4,2); obj.addElement(new Integer(3)); obj.addElement(new Integer(2)); obj.addElement(new Integer(6)); obj.insertElementAt(new Integer(8), 2); System.out.println(obj); } } |
| A. | [3, 2, 6]. |
| B. | [3, 2, 8]. |
| C. | [3, 2, 6, 8]. |
| D. | [3, 2, 8, 6]. |
| Answer» E. | |
| 931. |
What is the output of this program? import java.util.*; class vector { public static void main(String args[]) { Vector obj = new Vector(4,2); obj.addElement(new Integer(3)); obj.addElement(new Integer(2)); obj.addElement(new Integer(5)); System.out.println(obj.capacity()); } } |
| A. | 2 |
| B. | 3 |
| C. | 4 |
| D. | 6 |
| Answer» D. 6 | |
| 932. |
What is the output of this program? import java.util.*; class vector { public static void main(String args[]) { Vector obj = new Vector(4,2); obj.addElement(new Integer(3)); obj.addElement(new Integer(2)); obj.addElement(new Integer(5)); System.out.println(obj.elementAt(1)); } } |
| A. | 0 |
| B. | 3 |
| C. | 2 |
| D. | 5 |
| Answer» D. 5 | |
| 933. |
Which of these methods is used to add elements in vector at specific location? |
| A. | add() |
| B. | set() |
| C. | AddElement() |
| D. | addElement() |
| Answer» E. | |
| 934. |
What is the name of data member of class Vector which is used to store number of elements in the vector? |
| A. | length |
| B. | elements |
| C. | elementCount |
| D. | capacity |
| Answer» D. capacity | |
| 935. |
Which of these is the interface of legacy? |
| A. | Map |
| B. | Enumeration |
| C. | HashMap |
| D. | Hashtable |
| Answer» C. HashMap | |
| 936. |
Which of these are legacy classes? |
| A. | Stack |
| B. | Hashtable |
| C. | Vector |
| D. | All of the mentioned |
| Answer» E. | |
| 937. |
Which of these class object can be used to form a dynamic array? |
| A. | ArrayList |
| B. | Map |
| C. | Vector |
| D. | ArrayList & Vector |
| Answer» E. | |
| 938. |
What is the output of this program? import java.util.*; class Maps { public static void main(String args[]) { TreeMap obj = new TreeMap(); obj.put("A", new Integer(1)); obj.put("B", new Integer(2)); obj.put("C", new Integer(3)); System.out.println(obj.entrySet()); } } |
| A. | [A, B, C]. |
| B. | [1, 2, 3]. |
| C. | {A=1, B=2, C=3} |
| D. | [A=1, B=2, C=3]. |
| Answer» E. | |
| 939. |
What is the output of this program? import java.util.*; class Maps { public static void main(String args[]) { HashMap obj = new HashMap(); obj.put("A", new Integer(1)); obj.put("B", new Integer(2)); obj.put("C", new Integer(3)); System.out.println(obj.get("B")); } } |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | null |
| Answer» C. 3 | |
| 940. |
What is the output of this program? import java.util.*; class Maps { public static void main(String args[]) { HashMap obj = new HashMap(); obj.put("A", new Integer(1)); obj.put("B", new Integer(2)); obj.put("C", new Integer(3)); System.out.println(obj.keySet()); } } |
| A. | [A, B, C]. |
| B. | {A, B, C} |
| C. | {1, 2, 3} |
| D. | [1, 2, 3]. |
| Answer» B. {A, B, C} | |
| 941. |
What is the output of this program? import java.util.*; class Maps { public static void main(String args[]) { HashMap obj = new HashMap(); obj.put("A", new Integer(1)); obj.put("B", new Integer(2)); obj.put("C", new Integer(3)); System.out.println(obj); } } |
| A. | {A 1, B 1, C 1} |
| B. | {A, B, C} |
| C. | {A-1, B-1, C-1} |
| D. | {A=1, B=2, C=3} |
| Answer» E. | |
| 942. |
Which of these method is used add an element and corresponding key to a map? |
| A. | put() |
| B. | set() |
| C. | redo() |
| D. | add() |
| Answer» B. set() | |
| 943. |
Which of these methods can be used to obtain set of all keys in a map? |
| A. | getAll() |
| B. | getKeys() |
| C. | keyall() |
| D. | keyall() |
| Answer» E. | |
| 944. |
Which of these method Map class is used to obtain an element in the map having specified key? |
| A. | search() |
| B. | get() |
| C. | set() |
| D. | look() |
| Answer» C. set() | |
| 945. |
Which of these method is used to remove all keys/values pair from the invoking map? |
| A. | delete() |
| B. | remove() |
| C. | clear() |
| D. | removeAll() |
| Answer» C. clear() | |
| 946. |
Which of these classes provide implementation of map interface? |
| A. | ArrayList |
| B. | HashMap |
| C. | LinkedList |
| D. | LinkedList |
| Answer» C. LinkedList | |
| 947. |
Which of these object stores association between keys and values? |
| A. | Hash table |
| B. | map |
| C. | Array |
| D. | string |
| Answer» C. Array | |
| 948. |
What is the output of this program? import java.util.*; class Output { public static void main(String args[]) { TreeSet t = new TreeSet(); t.add("3"); t.add("9"); t.add("1"); t.add("4"); t.add("8"); System.out.println(t); } } |
| A. | [1, 3, 5, 8, 9]. |
| B. | [3, 4, 1, 8, 9]. |
| C. | [9, 8, 4, 3, 1]. |
| D. | [1, 3, 4, 8, 9]. |
| Answer» E. | |
| 949. |
What is the output of this program? import java.util.*; class Output { public static void main(String args[]) { HashSet obj = new HashSet(); obj.add("A"); obj.add("B"); obj.add("C"); System.out.println(obj + " " + obj.size()); } } |
| A. | ABC 3 |
| B. | [A, B, C] 3 |
| C. | ABC 2 |
| D. | [A, B, C] 2 |
| Answer» C. ABC 2 | |
| 950. |
What is the output of this program? import java.util.*; class Linkedlist { public static void main(String args[]) { LinkedList obj = new LinkedList(); obj.add("A"); obj.add("B"); obj.add("C"); obj.removeFirst(); System.out.println(obj); } } |
| A. | [A, B]. |
| B. | [B, C]. |
| C. | [A, B, C, D]. |
| D. | [A, B, C, D]. |
| Answer» C. [A, B, C, D]. | |