click below
click below
Normal Size Small Size show me how
oop mod 9 and 10
| Question | Answer |
|---|---|
| What type of exception is raised when we try run a program with objects that are not mutually comparable in a sorted map? | ClassCastException |
| There are no direct implementation of the Collection interface? | True |
| What type of collections are Lists? | Ordered |
| Which List class is synchronized? | Vector |
| Which method do we need to implement in the java.util.Comparator interface? | compare() |
| What type of collection does not extend the Collection interface? | map |
| Which of the following is a correct difference between HashSet and TreeSet? | HashSet maintains no order while TreeSet maintains ascending order. |
| Which of the following is a correct difference between the Iterator and Enumeration? | Iterator can traverse legacy and non-legacy containers whereas the Enumeration can traverse only legacy containers. |
| What type of ordering does a PriorityQueue have? | ordered and unsorted |
| What type of set would you use if you wanted it sorted? | treeset |
| Automatically created streams are attached with the GUI. | false |
| In Java, 2 streams are created for us automatically. | false |
| Java I/O is used to process the input and produce the output. | true |
| Java In/Ou is used to process the input and produce the output. | false |
| The display(int) method of OutputStream Class is used to write a byte to the current output stream. | false |
| In using FileWriter class, unlike FileOutputStream class, you don't need to convert string into byte array because it provides method to write string directly. | True |
| close() is a method of the FileWriter class that flushes the data of FileWriter. | false |
| Java ReadFile class is a character-oriented class which is used for file handling in java. | True |
| A method of the FileWriter class that is used to write char array into FileWriter. | write (char[] c) |
| Java FileReader class is used to read data from the file. | true |
| Which type of list implements the Queue interface | LinkedList |
| What do Lists have in common? | an index |
| Which of these is static variable defined in Collections? Group of answer choices All of the mentioned EMPTY_LIST EMPTY_SET EMPTY_MAP | all of the mentioned |
| Which of these interface declares core method that all collections will have? | collection |
| What is not true for the UnsupportedOperationException? | It occurs if a method is not found in the underlying collection. |
| What do maps care about Group of answer choices Index Uniqueness Speed | Uniqueness |
| What is the design pattern followed by Iterator? Group of answer choices Iterator design pattern None Observer design pattern Factory design pattern | iterator design pattern |
| You can't put null elements into Queues in the API? Group of answer choices true false | False |
| Can we have a sorted and unordered set? Group of answer choices Yes No | No |
| This the standard error stream. | system.err |
| The erase() method of OutputStream Class flushes the current output stream. Group of answer choices true false | false |
| ________ is used to process the input and produce the output. Group of answer choices Java I/O Java Collection Java Stream | Java I/O |
| A string is a sequence of data. Group of answer choices true false | false |
| A stream is a sequence of data. Group of answer choices true false | true |
| A method of the FileWriter class that flushes the data of FileWriter. Group of answer choices close() expel() exit() flush() | flush() |
| A method of the FileWriter class that is used to write the char into FileWriter. Group of answer choices create (char c) inscribe (char c) write (char c) engrave (char c) | write (char c) |
| A constructor of the FileReader class that creates a new file and get its file name in file objects. Group of answer choices FileReader (File file) FileReader (String file) FileReader (Character file) FileReader (Byte file) | FileReader (String file) |
| The FileReader (File file) is the constructor of the FileReader class that creates a new file and get its file name in file objects. Group of answer choices false true | False |
| In using FileWriter class, unlike FileOutputStream class, you don't need to convert string into byte array because it provides method to write string directly. Group of answer choices true false | true |
| Which List would you use if wanted fast access and were doing lots of insertions and deletions? | LinkedList |
| Which of the following is a benefit of using the Java Collections Framework? | coding shortcuts |
| What type of collection has always been type safe | arrays |
| HashMap maintains no order but TreeMap maintains ascending order. true or false | true |
| Which of the following class doesn't implement the Set interface? Group of answer choices LinkedHashSet TreeSet None of the above HashSet | none of the above |
| what is the correct difference between HashMap and Hashtable? | HashMap is not synchronized while the Hashtable is synchronized. |
| ________ is used to read data from a source; it may be a file, an array, peripheral device | InputStream |
| All are valid codes in printing error message in the console, except one. Group of answer choices System.err.print("Hello"); System.err.print="Hello"; System.err.printf("%s","Hello"); System.err.println("Hello"); | |
| An output stream accepts output bytes and sends them to some sink. Group of answer choices false true | False |
| What are we referring to when we mention java.util.Collections Group of answer choices The Collections framework A utilility class for use with collections We never mention this The interface from which lists, queues and sets extend | A utility class for use with collections |
| what is not true for the IdentityHashMap? | IdentityHashMap is synchronized. |
| Is the following code snippet valid? List aList = new ArrayList(); Group of answer choices No yes | no |
| How many ways does the java.lang.Comparable interface allow us to sort a collection? Group of answer choices 1 0 any number 2 | 1 |
| Which of these is static variable defined in Collections? Group of answer choices EMPTY_LIST All of the mentioned EMPTY_MAP EMPTY_SET | all of the mentioned |
| What type of set would you use if you wanted it sorted? Group of answer choices TreeSet HashSet LinkedHashSet | tree set |
| A PriorityQueue is always sorted in natural order? Group of answer choices false true | false |
| WeakHashMap doesn't allow null keys and null values. | WeakHashMap doesn't allow null keys and null values. |
| what is the difference between set and list? | List can hold duplicate elements while Set includes only unique elements. |
| What is the correct difference between HashMap and TreeMap? | HashMap maintains no order but TreeMap maintains ascending order. |
| The display(int) method of OutputStream Class is used to write a byte to the current output stream. Group of answer choices true false | false |
| The flush() method of OutputStream Class is used to close the current output stream. Group of answer choices true false | false |
| OutputString is used to write data to a destination; it may be a file, an array, peripheral device or socket. Group of answer choices true false | false |
| An output stream accepts output bytes and sends them to some sink. Group of answer choices false true | true |
| The display(byte[]) method of OutputStream Class is used to write an array of byte to the current output stream. Group of answer choices false true | false |
| read () is a method of the FileReader class that is used to return a character in ASCII form. It returns 0 at the end of file. Group of answer choices true false | true |
| System.error is the standard error stream. | False |
| System.util.Scanner is the standard input stream. | False |
| Can we have a sorted and unordered map? Group of answer choices Yes No | No |
| What type of variables can we use with the java.util.Arrays class? Group of answer choices primitive variables reference variables both neither | both |
| Which of the following is a correct difference between List and Set? | List can hold duplicate elements while Set includes only unique elements. |
| InputStream is used to read data from a source; it may be a file, an array, peripheral device or socket. Group of answer choices false true | True |
| Which of these is an incorrect form of using method max() to obtain maximum element? Group of answer choices max(List c) max(Collection c, Comparator comp) max(Collection c) max(Comparator comp) | max(Comparator comp) |
| Which of the following is a valid difference between Set and Map? | Set contains only values whereas Map contains key and values both. |
| The write(byte[]) method of OutputStream Class is used to write an array of byte to the current output stream. Group of answer choices true false | true |
| OutputStream is the superclass of all classes representing an output stream of bytes. Group of answer choices false true | False |
| Java FileReader class returns data in byte format like FileInputStream class. Group of answer choices true false | true |
| Which of the following is not true in case of a WeakHashMap? | WeakHashMap doesn't allow null keys and null values. |
| Which of these methods sets every element of a List to a specified object? Group of answer choices Complete() add() fill() set() | fill |
| If two arrays hold the same elements they are considered equal by the Arrays.equals() method? Group of answer choices true false | False |
| InputString is used to read data from a source; it may be a file, an array, peripheral device or socket. Group of answer choices true false | False |
| Set contains only values whereas Map contains key and values both. | Set contains only values whereas Map contains key and values both. |
| The java.util.io package contains all the classes required for input and output operations. Group of answer choices true false | true |