Interview Questions and Answers - Order By Newest Q31. Difference between Scanner and BufferedReader ? Which one is faster and Why ? Core Java
Ans. Scanner is used for parsing tokens from the contents of the stream while BufferedReader just reads the stream.
BufferedReader read files efficiently by using a buffer to avoid physical disk operations.
Buffer size of Scanner is usually smaller than the Buffered Writer.
BufferedReader is faster that Scanner as it just reads the Stream and doesn't Parse the tokens to read the stream into primitive data types. Sample Code for Scanner Sample Code for BufferedReader Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   file io   input output   scanner   bufferedreader  file handling Q32. Which of the following is true ? a. We can serialize static variables b. We can serialize transient variables c. We can serialize final variables d. We can serialize instance methods
Ans. We can serialize final variables Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  serialization   java   file io Try 1 Question(s) Test Q33. How and when the Buffer is cleared when using Buffered Writer Classes ? Core Java
Ans. Buffer is cleared in 2 circumstances, i.e 1. naturally when the buffer is filled and 2. explicitly when the method flush is called ( for flushing the residual )
Ideally we just need to call flush once at the end of file writing so that the residual content should be dumped to file. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  BufferedWriter  Writer  PrintWriter  File io  flush  file handling Q34. Have you ever tried compressing data using Java ? Core Java
Ans. Yes, we can use ZipInputStream class for compressing the FileInputstream object. Sample Code for ZipInputStream Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  FileInputstream  ZipInputStream  file handling Q35. Watching a directory for changes. Monitoring a directory. Core Java
Ans. http://www.logicbig.com/tutorials/core-java-tutorial/java-nio/java-watch-service/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  monitoring directory Q36. How to specify the sequence in which sub modules needs to be built ? Maven
Ans. By specifying the modules in the same sequence in the parent pom. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven  pom file  maven modules Q37. What is the difference between
File f = new File("homexyz.txt");
and
File f = File.createTempFile("xyz",".txt","home"); ? Core Java
Ans. First will not create physical file in storage whereas the second will. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  File.createTempFile  file handling intermediate   rare Q38. What are the different types of log files you have come across ? Logging
Ans. error , access , authentication , message , database etc Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  logging  log files  types of log files Q39. Upon compiling the following class, What .class files will get created
public class OuterClass{
class InnerClass{
}
}
Core Java
Ans. OuterClass.class AND OuterClass$InnerClass.class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  class files  compilation  compile  inner classes   nested classesAns. Its the Store Archive that holds the store Assets in the compressed form. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  SAR file  store archieve Q41. Why is it important to close files and streams ? Core Java
Ans. Optimizing Resource utilization. When you open a file using any programming language , that is actually a request to operating system to access the file. When such a request is made , resources are allocated by the OS. When you gracefully close those files, those resources are set free.
In Java if you don’t close the streams and files, Garbage collection identifies the open files which have lost the reference and hence will close them. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handlingAns. Access Control List or ACL is the list of permissions attached to an object in the File System. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  acl  file system  file security  object security  operating system Q43. What is the difference between RollingFile and RollingRandomAccessFile in log4j ?
Log4j
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  log4j  RollingFile  RollingRandomAccessFile Q44. What is the use of Property files ?
Ans. Property files are used to maintain configurable values as key value pairs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  config  property filesAns. It's an operating system file that maps IP address to host names. The hosts file assists the OS in addressing networked components and serves the function of translating human friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  host file  operating system Asked in 1 Companies Q46. As root, if you have to assign the owner for the file and set only read permission for the owner, Write a unix command to do it. Unix
Ans. chmod 477 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix commands  setting file permissions  chown  chmod Q47. In a file there are 1 million words . Find 10 most frequent words in that file. Design
This question was recently asked at 'Amazon'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling Asked in 1 Companies Q48. How to see last 500 lines of a log or text file Unix
Ans. tail -500 <FILE_NAME> Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix  log file Q49. Write code to read data from a file and write it to a file with 2 threads using the thread name content Core Java
This question was recently asked at 'verifone'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads  file  file handling Asked in 1 Companies Q50. How does encoding affect using Reader / writer classes or Stream classes in Java ? Core Java
Ans. Which group of bytes represent which character is defined by character encoding. So when reading character by character from a stream of bytes using Reader, specifying character encoding becomes significant as the same group of bytes can represent different character in different character encoding(Eg UTF-8 and UTF-16 etc.) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  File io  File handling  Reader  Writer  Stream Asked in 1 Companies Q51. Does Java generate .class file for interfaces ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  .class file  java byte code  interfaces Q52. Which jar files need to be included for using Hibernate ? Hibernate
Ans. hibernate-orm
hibernate-validator
hibernate-ogm
hibernate-search
or you can download hibernate core with all dependencies. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate jar files   hibernate Asked in 1 Companies