Java Questions 11 - 20  «Prev Next»

Java File Manipulation(Interview Questions)

  1. What does the java.io.file class encapsulate?

    Answer:
    The java.io.File class encapsulates access to information about a file or directory.
  2. Which 2 specialized streams for a) reading from and b) writing to files does Java provide ?

    Answer:
    1) File Input Stream 2) FileOutputStream
  3. What is object serialization?

    Answer:
    Object serialization is an automatic way to save and load the state of an object.
  4. What are transient fields in Java?

    Answer:
    Transient instances are not influenced by transactional methods like 1) begin 2) commit, or 3) rollback except when they are reachable by other persistent objects.
  5. What can you do in a subclass?

    Answer:
    A subclass inherits all of the public and protected members of its parent, no matter what package the subclass is in. If the subclass is in the same package as its parent, it also inherits the package-private members of the parent.
  6. What is persistence?

    Answer:
    Persistence focuses on taking the application specific information assets (the state in these objects) and making them available beyond the lifetime of the virtual machine process. The data should be available once the virtual machine has exited.
  7. What are some examples of persistence?

    Answer:
    1. Storing the state in a file
    2. Storing the state in a database using JDBC
    3. using serialization and storing the binary representation of the entire object
    4. leveraging the facilities of an application server using EJBs.
  8. What does NIO stand for in Java?

    Answer:
    new I/O: Much of the NIO functionality overlaps with existing APIs. NIO was added primarily to address specific issues of scalability for large systems, especially in networked applications.
  9. What defines the state or condition of an object?

    Answer:
    An object's attribute values, when taken collectively, are said to define the state.
  10. How is an object's behavior described?

    Answer:
    The behavior is also known as its operations and consists of 2 things.
    1. The things that an object does to access its attribute values
    2. The things that an object does to modify /maintain its attributed values (data)