Java 2

Intermediate Java programming covering string manipulation, exception handling, inheritance, access modifiers, and core Java classes

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What does the startIndex and endIndex argument in delete() method of StringBuffer class specify?

  1. Deletion of characters from startIndex position to endIndex position
  2. Deletion of characters from startIndex position to endIndex-1 position
  3. Deletion of all the characters
  4. Deletion of the startIndex and endIndex characters only
  5. Deletion of a single character only
Question 2 Multiple Choice (Single Answer)

Which of the following methods of Runtime class returns the approximate number of bytes of free memory available to the Java run-time system?

  1. gc()
  2. getRuntime()
  3. freeMemory()
  4. halt()
  5. totalMemory()
Question 3 Multiple Choice (Single Answer)

Which of the following methods in Integer class returns a string that contains the decimal equivalent of the invoking object?

  1. toString()
  2. toBinaryString()
  3. shortValue()
  4. parseInt()
  5. hashCode()
Question 4 Multiple Choice (Single Answer)

Which of the following conditions is incorrect for performing overriding of methods in Java?

  1. The method name in subclass must be identical to that of the superclass method.
  2. The return type of both the methods must be different.
  3. Methods of the superclass declared as public cannot be overrided using private keyword in the subclass.
  4. An overriding method cannot raise more exceptions than those raised by superclass.
  5. The overrided methods cannot have different number of arguments.
Question 5 Multiple Choice (Single Answer)

Which of the following interfaces in Java servlets indicates that the servlet is thread safe?

  1. ServletRequest
  2. ServletResponse
  3. SingleThreadModel
  4. Servlet
  5. ServletConfig
Question 6 Multiple Choice (Single Answer)

Which of the following blocks in Java is executed regardless of whether an exception is thrown or not?

  1. try block
  2. catch block
  3. finally block
  4. final
  5. private
Question 7 Multiple Choice (Single Answer)

Which of the following attributes of an Applet class specifies the path of the class file?

  1. CODE
  2. CODEBASE
  3. HEIGHT
  4. WIDTH
  5. ALIGN
Question 8 Multiple Choice (Single Answer)

Which of the following methods in a SmashTransition class is used to modify the work_pixels array for the next cell in Java?

  1. init()
  2. smash()
  3. tear()
  4. sleep()
  5. run()
Question 9 Multiple Choice (Single Answer)

Which of the following stream classes in Java creates and maintains a buffer for an input stream?

  1. FileInputStream
  2. FileOutputStream
  3. BufferedInputStream
  4. DataInputStream
  5. DataOutputStream
Question 10 Multiple Choice (Single Answer)

Which of the following methods in StringBuffer class is used to replace one set of characters with another set inside a StringBuffer object?

  1. substing()
  2. delete()
  3. deleteCharAt()
  4. insert()
  5. replace()
Question 11 Multiple Choice (Single Answer)

Which of the foolowing methods in StringBuffer class is used to set the length of the buffer within a StringBuffer object?

  1. length()
  2. ensureCapacity()
  3. charAt()
  4. setLength()
  5. getChars()
Question 12 Multiple Choice (Single Answer)

________ keyword is used in Java to prevent inheritance.

  1. public
  2. private
  3. final
  4. protected
  5. public protected
Question 13 Multiple Choice (Single Answer)

Which of the following types of accesses in Java allows a method to be accessible to all the classes of a package?

  1. Private access
  2. Protected access
  3. Default access
  4. Key access
  5. Large access
Question 14 Multiple Choice (Single Answer)

Which of the following methods is used in StringBuffer class to concatenate the string representation of any other type of data to the end of the invoking StringBuffer object?

  1. insert()
  2. reverse()
  3. delete()
  4. append()
  5. capacity()
Question 15 Multiple Choice (Single Answer)

Which of the following options in JAR command is used to create a new archive in Java?

  1. c
  2. C
  3. i
  4. M
  5. u