InputStream is used to read data from sources like File, Socket, or Console, while OutputStream is used to write data into a destination like a File, Socket, or Console.Ĥ. What is the difference between InputStream and OutputStream in Java? (answer) How do you create a file and directory in Java? ( answer)ģ. You can see the linked answer for more details.Ģ. This is tricky because there is no Directory class, File class is used to create both file and directory in Java. Which class is used to create a directory in Java? ( answer) Sometimes, these are also masked by in-house, proprietary APIs which further simplify IO work but nonetheless if you know these concepts, you can always find your way on IO related production issues and bugs.Īnyway, without wasting any more of your time, here is my list of some of the frequently asked Java IO interview questions:ġ. If you have worked as a Java developer for 2 to 3 years then most likely you can answer 60% of these questions, but if you can't then that's also fine because many Java developers don't get to work on IO as mostly other senior developers do. Some of them are easy, some of them are tricky, some are difficult, and some really tough questions. In this article, I'll share some of the popular Java IO based Interview questions. They will not only help you to write better Java applications but also immensely help you during Java interviews and give you an edge over other candidates.Ĥ3 Java IO and File Interview Questions with Answers Good knowledge of all these classes are imperative for any Java developer and if you feel that you haven't touched them yet or don't have enough experience with them, I suggest you join a comprehensive Java course like The Complete Java Masterclass Course by Tim Buchalaka on Udemy to learn them in depth. It contains classes like Channel, ByteBuffer, FileChannel, Selector which supports Multiplexing and Asynchronous IO. This is called New Input-Output or simply N-I-O package. This package is from the start of JDK and another package java.nio was introduced for better and faster IO facilities. They are mostly from the java.io package which is a core package in JDK but it's not automatically imported as java.lang. Java IO is nothing but a collection of classes that will help you to deal with reading input and writing output like File, Directory, InputStream, OutputStream, Reader, Writer, BufferedReader, BufferedWriter, Scanner, etc. If you are wondering what is Java IO or Java NIO then let me give you a brief overview. It won't be stuck as Draft anymore and can potentially benefit Java developers looking for Java IO Interview questions. This year, I am trying to clear all those backlogs and so I thought to leverage the many in-depth articles I have shared on Java IO and NIO on my blog Javarevisited and Java67, and this way I can at least publish this post out and improve upon based upon the feedback. One reason for the delay was because I was aiming to create a really big post with 100+ questions and answers in the same place, just like I did for Core Java Interview Questions earlier, but that didn't happen and this post got stuck. Consequently, many of my readers were also asking about Java IO and File-based interview questions and this was one of the pending items on my TODO list for quite some time. In the past, I have shared many Java interview questions on topics like Collections, Concurrency, JVM internals, Garbage Collection, OOP, Design Patterns, and Data structure based coding problems, which received good feedback and helped many Java developer on their Java Interview preparation. Good knowledge of Java IO API is important for any Java developer but many of them barely pay attention to Java IO and NIO API, and that's why they often struggle during Java interviews when a question related to Input-Output operation is asked.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |