0

Input/Output in Java

Description: Input/Output in Java
Number of Questions: 15
Created by:
Tags: Input/Output in Java Java/Oracle /C/C++ Java
Attempted 0/15 Correct 0 Score 0

Which of the following methods is used to extract a single character from a string?

  1. getChars()

  2. getBytes()

  3. toCharArray()

  4. charAt()

  5. equalsIgnoreCase()


Correct Option: D
Explanation:

This method is used to extract a single character from a string.

The _______________ method searches for the first occurrence of a character or substring.

  1. equals()

  2. indexOf()

  3. startWith()

  4. endWith()

  5. lastIndexOf()


Correct Option: B
Explanation:

This method searches for the first occurrence of a character or substring.

Which of the following methods is used to pre-allocate a space for a certain number of characters, after a StringBuffer has been constructed?

  1. setLength()

  2. length()

  3. capacity()

  4. startWith()

  5. ensureCapacity()


Correct Option: D
Explanation:

This method is used to pre-allocate a space for a certain number of characters, after a StringBuffer has been constructed. This method determines whether a given string begins with a specified string or not.

Which of the following methods returns the value of the invoking object as a byte?

  1. float Value()

  2. long Value()

  3. int Value()

  4. the short short Value()

  5. byte Value()


Correct Option: E
Explanation:

This method returns the value of the invoking object of the type 'byte'.

Which of the following methods is used to find the execution of the various parts of a program?

  1. arraycopy()

  2. currentTimeMillis()

  3. clone()

  4. digit()

  5. none of these


Correct Option: B
Explanation:

This method is used to find the execution time of the various parts of the program.

The _________ method is used to perform a comparison that ignores the case differences, i.e. it considers A - Z to be the same as a - z.

  1. trim()

  2. equalsIgnoreCase()

  3. equals()

  4. indexOf()

  5. capacity()


Correct Option: B
Explanation:

This method is used to perform a comparison that ignores the case differences, i.e. when it compares two strings, it considers A-Z to be the same as a-z.

Which of the following methods returns true, if the invoking object contains infinite values?

  1. boolean is Infinite()

  2. boolean is NaN()

  3. int hashCode()

  4. double Value()

  5. none of these


Correct Option: A
Explanation:

This method returns the value true, if the invoking object contains infinite values.

Which of the following methods returns the total number of bytes of the memory available to a program?

  1. void gc()

  2. void runFinalisation()

  3. long totalMemory()

  4. int exitValue()

  5. long freeMemory()


Correct Option: C
Explanation:

This method returns the total number of bytes of the memory avaliable to a program.

Which of the following methods displays the call stack for threads?

  1. void checkAccess()

  2. void destroy()

  3. void interrupt()

  4. static void dumpStack()

  5. void run()


Correct Option: D
Explanation:

This method displays the call stack for the thread.

The ___________ method determines whether the string in the question ends with a specified string or not.

  1. endWith()

  2. int hashCode()

  3. arraycopy()

  4. int exitValue()

  5. int hashCode()


Correct Option: A
Explanation:

This method determines whether the string in the question ends with a specified string or not.

If we want to convert all the characters in a String object into a character array, we use the _________ method.

  1. toCharArray()

  2. regionMatches()

  3. trim()

  4. replace()

  5. endWith()


Correct Option: A
Explanation:

If we want to convert all the characters in a string object into a character array, we use the method toCharArray().

Which of the following package methods returns the name of the invoking package?

  1. String getName()

  2. String getImplementationTitle()

  3. String getImplementationVersion()

  4. String getImplementationVendor()

  5. String getSpecificationTitle()


Correct Option: A
Explanation:

This method returns the name of the invoking package.

Which of the following interfaces enables you to work with a group of objects?

  1. Collection

  2. List

  3. Set

  4. SortedSet

  5. SecurityManager


Correct Option: A
Explanation:

This interface enables you to work with a group of objects.

______________ collection class extends the AbstractList for a collection that uses sequential access, rather than the random access of its elements.

  1. Abstract

  2. AbstractSequentialList

  3. AbstractList

  4. LinkedList

  5. AbstractSet


Correct Option: B
Explanation:

This collection class extends the AbstractList for a collection that uses sequential access, rather than the random access of its elements.

Which of the following thread group methods returns the number of threads in a group, along with the group, for which this thread is a parent?

  1. int activeGroupCount()

  2. final void destroy()

  3. final int getMaxPriority()

  4. int activeCount()

  5. none of these


Correct Option: D
Explanation:

This method returns the number of threads in the group, along with a group, for which this thread is a parent.

- Hide questions