Java 2
Intermediate Java programming covering string manipulation, exception handling, inheritance, access modifiers, and core Java classes
Questions
What does the startIndex and endIndex argument in delete() method of StringBuffer class specify?
- Deletion of characters from startIndex position to endIndex position
- Deletion of characters from startIndex position to endIndex-1 position
- Deletion of all the characters
- Deletion of the startIndex and endIndex characters only
- Deletion of a single character only
Which of the following methods of Runtime class returns the approximate number of bytes of free memory available to the Java run-time system?
- gc()
- getRuntime()
- freeMemory()
- halt()
- totalMemory()
Which of the following methods in Integer class returns a string that contains the decimal equivalent of the invoking object?
- toString()
- toBinaryString()
- shortValue()
- parseInt()
- hashCode()
Which of the following conditions is incorrect for performing overriding of methods in Java?
- The method name in subclass must be identical to that of the superclass method.
- The return type of both the methods must be different.
- Methods of the superclass declared as public cannot be overrided using private keyword in the subclass.
- An overriding method cannot raise more exceptions than those raised by superclass.
- The overrided methods cannot have different number of arguments.
Which of the following interfaces in Java servlets indicates that the servlet is thread safe?
- ServletRequest
- ServletResponse
- SingleThreadModel
- Servlet
- ServletConfig
Which of the following blocks in Java is executed regardless of whether an exception is thrown or not?
- try block
- catch block
- finally block
- final
- private
Which of the following attributes of an Applet class specifies the path of the class file?
- CODE
- CODEBASE
- HEIGHT
- WIDTH
- ALIGN
Which of the following methods in a SmashTransition class is used to modify the work_pixels array for the next cell in Java?
- init()
- smash()
- tear()
- sleep()
- run()
Which of the following stream classes in Java creates and maintains a buffer for an input stream?
- FileInputStream
- FileOutputStream
- BufferedInputStream
- DataInputStream
- DataOutputStream
Which of the following methods in StringBuffer class is used to replace one set of characters with another set inside a StringBuffer object?
- substing()
- delete()
- deleteCharAt()
- insert()
- replace()
Which of the foolowing methods in StringBuffer class is used to set the length of the buffer within a StringBuffer object?
- length()
- ensureCapacity()
- charAt()
- setLength()
- getChars()
________ keyword is used in Java to prevent inheritance.
- public
- private
- final
- protected
- public protected
Which of the following types of accesses in Java allows a method to be accessible to all the classes of a package?
- Private access
- Protected access
- Default access
- Key access
- Large access
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?
- insert()
- reverse()
- delete()
- append()
- capacity()
Which of the following options in JAR command is used to create a new archive in Java?
- c
- C
- i
- M
- u