Misael Pinedo
Test por , creado hace más de 1 año

|

7
0
0
Misael Pinedo
Creado por Misael Pinedo hace más de 9 años
Cerrar

Java 2

Pregunta 1 de 31

1

What is the difference between iterator access and index access?

Selecciona una o más de las siguientes respuestas posibles:

  • Index 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.

  • In Iterator based access, the cursor has to traverse through each element to get the desired element.

  • Insertion, updation or deletion will be faster for index based access if the operations are performed on elements present at at last of the datastructure.

  • Insertion, updation or deletion will be faster for iterator based access if the operations are performed on elements present in between the datastructure

  • Insertion, updation or deletion will be faster for iterator based access if the operations are performed on elements present at at last of the datastructure.

  • Insertion, updation or deletion will be faster for index based access if the operations are performed on elements present in between the datastructure

  • ArrayList is index access and LinkedList is iterator access

  • ArrayList is iterator access and LinkedList is index access

Explicación

Pregunta 2 de 31

1

How to sort a list in reverse order?

Selecciona una o más de las siguientes respuestas posibles:

  • List list = new ArrayList();
    Comparator comp = Collections.reverseOrder();
    Collections.sort(list, comp)

  • List list = new ArrayList();
    Collections.sort(list, comp)

  • List list = new ArrayList();
    Comparator comp = Collections.reverseOrder();
    Collections.sortReverse(list, comp)

Explicación

Pregunta 3 de 31

1

Can a null element be added to a TreeSet or HashSet?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 4 de 31

1

How to sort list of strings - case sensitive?

Selecciona una de las siguientes respuestas posibles:

  • Collections.sort(list,String.CASE_INSENSITIVE_ORDER);

  • Collections.sort(list,String.CASE_SENSITIVE_ORDER);

  • Collections.sort(list,String.SENSITIVE_ORDER);

Explicación

Pregunta 5 de 31

1

How to make a list unmodifiable (ArrayList, Vector, LinkedList)

Selecciona una de las siguientes respuestas posibles:

  • Collections.unmodifiableList(list)

  • Collections.readOnly(list)

  • Collections.nonmodifiable(list)

Explicación

Pregunta 6 de 31

1

Is 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

Selecciona una de las siguientes respuestas posibles:

  • ConcurrentHashMap

  • LinkedHashSet

Explicación

Pregunta 7 de 31

1

Which is faster to iterate LinkedHashSet or LinkedList?

Selecciona una de las siguientes respuestas posibles:

  • LinkedHashSet

  • LinkedList

Explicación

Pregunta 8 de 31

1

Which data structure HashSet Implements?

Selecciona una de las siguientes respuestas posibles:

  • Implements hashmap internally to store the data

  • Implements linkedlist internally to store the data

Explicación

Pregunta 9 de 31

1

What is identityHashMap?

Selecciona una de las siguientes respuestas posibles:

  • Uses == for equality checking instead of equals()

  • Uses equals() for equality checking instead of ==

Explicación

Pregunta 10 de 31

1

What is an exception?

Selecciona una de las siguientes respuestas posibles:

  • Is 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.

  • Is 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.

Explicación

Pregunta 11 de 31

1

Exceptions are defined in which java package?

Selecciona una de las siguientes respuestas posibles:

  • All the exceptions are subclasses of java.lang.Exception

  • All the exceptions are subclasses of java.lang.com.Exception

Explicación

Pregunta 12 de 31

1

Try-catch-finally block is...

Selecciona una de las siguientes respuestas posibles:

  • The way java handles exceptions

  • a form of iteration between collections

Explicación

Pregunta 13 de 31

1

Characteristics of Runtime Exception

Selecciona una o más de las siguientes respuestas posibles:

  • represent 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.

  • exceptions 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.

  • exceptions which forces the programmer to catch them explicitly in try-catch block.

  • is called also unchecked exception

Explicación

Pregunta 14 de 31

1

What is the difference between error and exception?

Selecciona una o más de las siguientes respuestas posibles:

  • An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. The application will come to a halt and is not recoverable

  • An exception is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. The application will come to a halt and is not recoverable

  • Exceptions 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.)

  • Errors 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.)

Explicación

Pregunta 15 de 31

1

What is ClassNotFoundException?

Selecciona una de las siguientes respuestas posibles:

  • Is thrown when the reported class isnot found by the ClassLoader in the CLASSPATH

  • Is thrown when the calss in question has static blocks or members which use a Class that is not found in the ClassLoader

Explicación

Pregunta 16 de 31

1

What is NoClassDefFoundError?

Selecciona una de las siguientes respuestas posibles:

  • Is thrown when the reported class is not found by the ClassLoader in the CLASSPATH

  • Is thrown when the class in question has static blocks or members which use a class that is not found by the ClassLoader

Explicación

Pregunta 17 de 31

1

Is used to throw the exception manually

Selecciona una de las siguientes respuestas posibles:

  • throw keyword

  • try-catch block

Explicación

Pregunta 18 de 31

1

What is the use of throws keyword?

Selecciona una de las siguientes respuestas posibles:

  • if the function is not capable of handling the exception then it can ask the calling method to handle the exception

  • It is used to throw the exception manually

Explicación

Pregunta 19 de 31

1

How to create custom exceptions?

Selecciona una de las siguientes respuestas posibles:

  • Extend the exception class or any of its subclasses

  • Override methods from the Exception class of your preference.

Explicación

Pregunta 20 de 31

1

When to make a custom checked Exception?

Selecciona una de las siguientes respuestas posibles:

  • If the application can recover from an exception

  • If the application cant do nothing to recover from the exception

Explicación

Pregunta 21 de 31

1

When to make an unchecked exception?

Selecciona una de las siguientes respuestas posibles:

  • When the application can do something to recover from an exception

  • When the applications can not do anything to recover from an exception

Explicación

Pregunta 22 de 31

1

What is a StackOverflowError?

Selecciona una de las siguientes respuestas posibles:

  • Is 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

  • Is 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

Explicación

Pregunta 23 de 31

1

Once the control reaches the catch block does it returns back to the try block?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 24 de 31

1

What is the purpose of the finally block?

Selecciona una de las siguientes respuestas posibles:

  • If an exception is or is not thrown the finally block is reached and there you can tipically release connections, closing of result, etc.

  • Be executed just if an exception is thrown

  • Finalize the actions of the code no matter what action was performed in the try-catch block

Explicación

Pregunta 25 de 31

1

Is valid to have a try block without catch or finally?

Selecciona una o más de las siguientes respuestas posibles:

  • Yes, the try block is the only thing that matters

  • No. This will result in a compilation error

  • No. The try block must be followed by a catch or a finally block

Explicación

Pregunta 26 de 31

1

What is the method that allows to print the descriptive information about the exception ocurred during the program execution?

Selecciona una de las siguientes respuestas posibles:

  • printStackTrace()

  • println()

  • print()

Explicación

Pregunta 27 de 31

1

Is a good practice to write a single catch all handler to catch all the exceptions?

Selecciona una de las siguientes respuestas posibles:

  • No, 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

  • Yes, because you will save lines of code if you do not write all those try-catch blocks

Explicación

Pregunta 28 de 31

1

What is exception matching?

Selecciona una de las siguientes respuestas posibles:

  • is the process by which the jvm finds out the matching catch block for the exception thrown from the list of catch blocks

  • is the process where the JVM matchs blocks of try catch to use the best

Explicación

Pregunta 29 de 31

1

How the exceptions must be placed in a try catch block? (because if are handled incorrectly it will result in a compilation error)

Selecciona una de las siguientes respuestas posibles:

  • Most specific exceptions must always be placed above the catch block written to handle more general exceptions

  • More general exceptions must always be placed above the catch block written to handle more specific exceptions

Explicación

Pregunta 30 de 31

1

If the exceptions are siblings in the Exception class's hierarchy when placed in multiple catch block, does it matter in what position are placed?

Selecciona una de las siguientes respuestas posibles:

  • No, if they are not subtypes or supertypes of each other

  • Yes, always the more specific exception must be caught first

Explicación

Pregunta 31 de 31

1

What does Ducking the exception mean?

Selecciona una de las siguientes respuestas posibles:

  • If 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.

  • Is a type of exception that happens only when the exception is rethrown again in the same catch block

Explicación