Quiz
Java 2
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (31)
1What is the difference between iterator access and index access?
- AIndex based access allow access of the element directly on the basis of index The cursor of the datastructure can directly go to the 'n' location and get the element.
- BIn Iterator based access, the cursor has to traverse through each element to get the desired element.
- CInsertion, updation or deletion will be faster for index based access if the operations are performed on elements present at at last of the datastructure.
- DInsertion, updation or deletion will be faster for iterator based access if the operations are performed on elements present in between the datastructure
- EInsertion, updation or deletion will be faster for iterator based access if the operations are performed on elements present at at last of the datastructure.
- FInsertion, updation or deletion will be faster for index based access if the operations are performed on elements present in between the datastructure
- GArrayList is index access and LinkedList is iterator access
- HArrayList is iterator access and LinkedList is index access
2How to sort a list in reverse order?
- AList list = new ArrayList();
Comparator comp = Collections.reverseOrder();
Collections.sort(list, comp) - BList list = new ArrayList();
Collections.sort(list, comp) - CList list = new ArrayList();
Comparator comp = Collections.reverseOrder();
Collections.sortReverse(list, comp)
- AList list = new ArrayList();
3Can a null element be added to a TreeSet or HashSet?
- ATrue
- BFalse
4How to sort list of strings - case sensitive?
- ACollections.sort(list,String.CASE_INSENSITIVE_ORDER);
- BCollections.sort(list,String.CASE_SENSITIVE_ORDER);
- CCollections.sort(list,String.SENSITIVE_ORDER);
5How to make a list unmodifiable (ArrayList, Vector, LinkedList)
- ACollections.unmodifiableList(list)
- BCollections.readOnly(list)
- CCollections.nonmodifiable(list)
6Is a thread-safe implementation of Map Interface. In this class put and remove method are synchronized but not the get method. Better than HashTable in terms of performance
- AConcurrentHashMap
- BLinkedHashSet
7Which is faster to iterate LinkedHashSet or LinkedList?
- ALinkedHashSet
- BLinkedList
8Which data structure HashSet Implements?
- AImplements hashmap internally to store the data
- BImplements linkedlist internally to store the data
9What is identityHashMap?
- AUses == for equality checking instead of equals()
- BUses equals() for equality checking instead of ==
10What is an exception?
- AIs said to be thrown whenever an exceptional event occurs in java which signals that something is not correct with the code written an may give unexpected results.
- BIs said to be thrown whenever an exceptional event occurs in java which signals that something is not correct with the code written an may expected results.
11Exceptions are defined in which java package?
- AAll the exceptions are subclasses of java.lang.Exception
- BAll the exceptions are subclasses of java.lang.com.Exception
12Try-catch-finally block is...
- AThe way java handles exceptions
- Ba form of iteration between collections
13Characteristics of Runtime Exception
- Arepresent problems that are the result of a programming problem. Such problems include arithmetic exceptions, such as dividing by zero; pointer exceptions: such as trying to access an object through a null reference; and indexing exceptions: such as attempting to access an array element through an index that is too large or too small.
- Bexceptions need not be explicitly caught in try catch block as it can occur anywhere in a program, and in a typical one they can be very numerous.
- Cexceptions which forces the programmer to catch them explicitly in try-catch block.
- Dis called also unchecked exception
14What is the difference between error and exception?
- AAn error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. The application will come to a halt and is not recoverable
- BAn exception is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. The application will come to a halt and is not recoverable
- CExceptions are conditions that occur because of bad input or human error. Like a FileNotFoundException or a NullPointerException. In most of these cases its possible to recover from an exception (probably by giving user a feedback for entering proper values etc.)
- DErrors are conditions that occur because of bad input or human error. Like a FileNotFoundException or a NullPointerException. In most of these cases its possible to recover from an exception (probably by giving user a feedback for entering proper values etc.)
15What is ClassNotFoundException?
- AIs thrown when the reported class isnot found by the ClassLoader in the CLASSPATH
- BIs thrown when the calss in question has static blocks or members which use a Class that is not found in the ClassLoader
16What is NoClassDefFoundError?
- AIs thrown when the reported class is not found by the ClassLoader in the CLASSPATH
- BIs thrown when the class in question has static blocks or members which use a class that is not found by the ClassLoader
17Is used to throw the exception manually
- Athrow keyword
- Btry-catch block
18What is the use of throws keyword?
- Aif the function is not capable of handling the exception then it can ask the calling method to handle the exception
- BIt is used to throw the exception manually
19How to create custom exceptions?
- AExtend the exception class or any of its subclasses
- BOverride methods from the Exception class of your preference.
20When to make a custom checked Exception?
- AIf the application can recover from an exception
- BIf the application cant do nothing to recover from the exception
21When to make an unchecked exception?
- AWhen the application can do something to recover from an exception
- BWhen the applications can not do anything to recover from an exception
22What is a StackOverflowError?
- AIs an Error Object thrown by the Runtime System when it Encounters that your application/code has ran out of memory. It may occur in case of recursive methods or a large amount of data is fetched from the server and stored in some object. This error is generated by JVM
- BIs an Error Object thrown by the Runtime System when it Encounters that your application/code has ran out of memory. It does not may occur in case of recursive methods or a small amount of data is fetched from the server and stored in some object. This error is generated by JVM
23Once the control reaches the catch block does it returns back to the try block?
- ATrue
- BFalse
24What is the purpose of the finally block?
- AIf an exception is or is not thrown the finally block is reached and there you can tipically release connections, closing of result, etc.
- BBe executed just if an exception is thrown
- CFinalize the actions of the code no matter what action was performed in the try-catch block
25Is valid to have a try block without catch or finally?
- AYes, the try block is the only thing that matters
- BNo. This will result in a compilation error
- CNo. The try block must be followed by a catch or a finally block
26What is the method that allows to print the descriptive information about the exception ocurred during the program execution?
- AprintStackTrace()
- Bprintln()
- Cprint()
27Is a good practice to write a single catch all handler to catch all the exceptions?
- ANo, If you use the Superclass Exception in the catch block you will not receive valuable information about each of the exception thrown during the execution. All so it will increase the difficutly to read the code since you are not gonna know what is the exact reason of the try-catch
- BYes, because you will save lines of code if you do not write all those try-catch blocks
28What is exception matching?
- Ais the process by which the jvm finds out the matching catch block for the exception thrown from the list of catch blocks
- Bis the process where the JVM matchs blocks of try catch to use the best
29How the exceptions must be placed in a try catch block? (because if are handled incorrectly it will result in a compilation error)
- AMost specific exceptions must always be placed above the catch block written to handle more general exceptions
- BMore general exceptions must always be placed above the catch block written to handle more specific exceptions
30If the exceptions are siblings in the Exception class's hierarchy when placed in multiple catch block, does it matter in what position are placed?
- ANo, if they are not subtypes or supertypes of each other
- BYes, always the more specific exception must be caught first
31What does Ducking the exception mean?
- AIf a method does not throw directly a checked exception but calls a method that does that and that method declares the exception but is not handled, then the calling method must handle the exception using throws.
- BIs a type of exception that happens only when the exception is rethrown again in the same catch block
Information
- Description
- |
- Author
- Misael Pinedo
- Language
- Español
- Views
- 19
- Tags
- Rating
- No ratings yet Rate this quiz