OOPS and Core Java Interview Question and Answers

13. Define a stream in Java?
  A stream is an abstraction that either produces or consumes information. Java programs perform I/O through streams.
 
Your Name Your Email-ID
Your Answer
14. What is an object Serialization?
 
  • Serialization is the process of writing the state of an object to a byte stream.
  • It is used when a state of program has to be saved to a persistent storage area, such as a file.
  • It is also required to implement the Remote Method Invocation (RMI).
  • RMI allows a Java object on one machine to invoke a method of a Java object on a different machine.
  • An object may be supplied as an argument to that remote method.
  • The sending machine serializes the object and transmits it.
 
Your Name Your Email-ID
Your Answer
15. What is the difference between StringBuilder and StringBuffer class?
  It is very much similar to StringBuffer except for one difference: it is not synchronized, which means that is is not thread safe. The advantage of StringBuilder is good performance. In case of multithreading you must use StringBuffer rather than StringBuilder.
 
Your Name Your Email-ID
Your Answer
16. What is the difference between Abstract classes and Interfaces?
 
  • Abstract class can only be inherited while interfaces cannot be it has to be, implemented.
  • Interface cannot implement any methods, whereas an abstract class can have implementation.
  • Class can implement many interfaces but can have one super class.
  • Interface is not part of the class hierarchy while Abstract class comes in through inheritance.
  • Unrelated classes can implement the same interface.
 
Your Name Your Email-ID
Your Answer
12345678910 Page 4 of 10