HOME      BLOG       FORUMS      CONTACT       ABOUT

Core Java interview questions – Part 12

181. What is an Object and how do you allocate memory to it?
Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.

182. What is UNICODE?
Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

183. What is adapter class?
An adapter class provides a default implementation of all methods in an event listener interface. Adapter classes are useful when you want to process only some of the events that are handled by a particular event listener interface. You can define a new class by extending one of the adapter classes and implementing only those events relevant to us.

184. What is a stream and what are the types of Streams and classes of the Streams?
A stream is a flow of data from one direction to another. . There are two types of Streams Byte Streams: Provide a convenient means for handling input and output of bytes. And Character Streams: Provide a convenient means for handling input & output of characters.

185. What is the difference between TCP/IP and UDP?
TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. UDP is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination.

186. What is Inter-Thread communication?.
Exchange of information between two threads.

187. What is a policy?.
It’s an abstract class for representing the system security policy for a Java application environment (specifying which permissions are available for code from various sources). Java security properties file resides in /lib/security/java.security directory.

188. What is a thread group?
A thread group is a data structure that controls the state of collection of thread as a whole managed by the particular runtime environment.

189. Why is UTFDataFormatException thrown by DataOutputStream.writeUTF() when serializing a String?
DataOutputStream.writeUTF() does not support writing out strings larger than 64K. The first two bytes of a UTF string in the stream are the length of the string. If a java.lang.String is larger than 64K, it needs to be stored in the stream by an alternative method rather than depending on the default method of storing a String in the stream, writeUTF.

190. Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?
The ObjectOutputStream maintains a table mapping objects written into the stream to a handle. The first time an object is written to a stream, its contents are written into the stream; subsequent writes of the object result in a handle to the object being written into the stream. This table maintains references to objects that might otherwise be unreachable by an application, thus, resulting in an unexpected situation of running out of memory. A call to the ObjectOutputStream.reset() method resets the object/handle table to its initial state, allowing all previously written objects to be eligible for garbage collection.

191. How can I get the serialVersionUID of a class?
By running the serialver tool with the name of the class as the command line argument, as shown in the example that follows: serialver java.lang.String

192. What is serialVersionUID ?
The serialVersionUID is a universal version identifier for a Serializable class. Deserialization uses this identifier number to ensure that a loaded class corresponds to a serialized object.

193. What is abstraction?
An abstraction is an idea, concept, or word which defines the phenomena which make up the concrete events or things which the abstraction refers to, the referents.

194. What is encapsulation?
Encapsulation describes the ability of an object to hide its data and methods from the rest of the world

195. What is inheritance?
Inheritance is the ability to create new classes based on existing classes. It is useful to reuse existing code.

Share

Tags: , , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply