DefNeo
Level 36

Level 32

Published in the Random EN group
Level 32
  1. Why is it needed RandomAccessFile?

    RandomAccessFile- a class of the Java IO API package, it allows you to navigate through the file, read from it or write to it as you please. You can also replace the existing parts of the file, we are talking about updating the contents of the file, or rather, updating a fragment of the file. This cannot be done with FileInputStreamor FileOutputStream, but RandomAccessFilewill give you that option.

    Reference: RandomAccessFile and its features

  2. What happens if the file it is reading from RandomAccessFiledoes not exist?

    WillFileNotFoundException

  3. What happens if the file it writes to RandomAccessFiledoesn't exist?

    Create a new one and write to it.

  4. Why is a class needed StringReader?

    The Java.io.StringReader class is a character stream whose source is a string.

    Represents a stream of characters whose source is called a string

  5. Why is a class needed StringWriter?

    public class StringWriter
    extends Writer

    A character stream that collects its output in a string buffer, which can then be used to construct a string.

    Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

    A stream of characters that collects its stream into a buffer of strings, which can then be used to create a string.

  6. Why is a class needed ByteArrayStream?

    So, ByteArrayInputStreamand ByteArrayOutputStream.

    These classes are essentially something similar to StringReaderand < code="">. Only StringReaderread characters (char) from a string (String), but ByteArrayInputStreamreads bytes from a byte array (ByteArray). <>

    StringWriterwrote characters (char) to a string, but ByteArrayOutputStreamwrites bytes to an array of bytes inside it. When writing to StringWriterthe string inside it lengthened, and when writing to ByteArrayOutputStreamits internal byte array, it also dynamically expanded.

  7. Why is a class needed PrintStream? Name the places where it is used?

    The class PrintStreamhas been thought up for a readable output of the information. It almost entirely consists of methods printand println.

  8. Why is it needed DynamicProxy?

    Java has a special class (java.lang.reflect.Proxy) with which you can actually construct an object at runtime (dynamically) without creating a separate class for it.

  9. How does RMI work?

    RMI stands for Remote Method Invokation - remote method invocation. Or in other words, RMI is a mechanism that allows an object in one Java machine to call methods of an object in another Java machine, even if they are on different computers, in different countries, on different sides of the globe.

    The traditional approach to executing code on other machines spread over a network can be confusing because of its tedious and error-prone implementation. The best way to deal with this problem is to assume that some objects are located on a different machine, and that you can send messages to these remote objects and get the result as if they were on your local machine. This simplification is exactly what allows Remote Method Invocation (RMI) in Java.

    Here is an article on creating your own RMI implementation: Remote Method Invocation (RMI)

  10. What types of objects can be passed over RMI?

    Objects must implement an interfaceSerializable

    Remote method Invocation is a mechanism that allows you to call a method on a remote object. According to it, all data preparation and transfer operations are encapsulated in the called method of the client stub object (stub). The method call itself is no different from calling the method of an ordinary local object, with a small exception:

    • local objects are passed by value (copy);
    • when passing a remote ( Remote) object, if it is exported, the stub of this object is passed;
    • passed objects must be Serializable;
    • in addition to all other exceptional situations, when calling a remote method, an exception may be raised RemoteException(marshalization / unmarshalization errors, data transfer errors and other possible protocol errors);

    It should also be noted that when calling a method, we are working with a remote interface, and not with a remote class.

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION