Tuesday, 31 January 2012
- It is use for reading stream of data from a file in the form of raw bytes(8-bit).
- Very useful to read image.
- It can also read character files.
Tuesday, 31 January 2012 by Anijit Sarkar · 4 Read more »
Sunday, 29 January 2012
- Nested class which is declared static is static nested class.
- Its methods & variables are associated with is mother/outer class.
- It can be used only through object reference.
- It is accessed using enclosing class name. Example: MotherClass.StaticNestedClass
- It interacts with enclosing class or other class like any other top-level class.
Sunday, 29 January 2012 by Anijit Sarkar · 21 Read more »
Saturday, 28 January 2012
Whereas, throws is included in the method's declaration part, with a list of exceptions that the method can possible throw. It is necessary for all exceptions(except for Error & RuntimeException & their sub-classes).
Saturday, 28 January 2012 by Anijit Sarkar · 25 Read more »
Friday, 27 January 2012
- Once an object is created and initialized, it can't be changed because it is Immutable.
- String object can be created Implicitly and Explicitly.
StringBuffer class :
- StringBuffer class is mutable(can be modified), length and content can be changed through certain method calls.
- It creates object Explicitly.
Friday, 27 January 2012 by Anijit Sarkar · 1 Read more »
Wednesday, 25 January 2012
Wednesday, 25 January 2012 by Anijit Sarkar · 54 Read more »
Saturday, 21 January 2012
Exception class:
- It is used for exceptional conditions that user programs should catch.
- It's also the class that you will sub-class to create your own custom exception types.
- For example, NullPointerException will be thrown if you try using a null reference.
Saturday, 21 January 2012 by Anijit Sarkar · 5 Read more »
Thursday, 19 January 2012
- Container is a component which can contain other components inside itself. It is also an instance of a subclass of
java.awt.Container
, which extendsjava.awt.Component
. - An applet is a container.
- Containers include windows, frames, dialogs, and panels.
- As a Container itself is a component, it can contain other containers.
- Every container has a
LayoutManager
which helps to determines how different components are placed within the container.
Thursday, 19 January 2012 by Anijit Sarkar · 6 Read more »
Wednesday, 18 January 2012
- Except RuntimeException( java.lang.RuntimeException) class, all sub-classes of Exception are checked exception.
- These exceptions need to include in a method's throws list, because these are checked by the compiler during compile time if a method handles or throws these exception.
Wednesday, 18 January 2012 by Anijit Sarkar · 1 Read more »
by Anijit Sarkar · 10 Read more »
Tuesday, 17 January 2012
2. It has two methods readExternal and writeExternal, which are use to customize the serialization process.
Tuesday, 17 January 2012 by Anijit Sarkar · 0 Read more »
2. If the state of an object is to be saved, objects need to be serialized.
by Anijit Sarkar · 3 Read more »
by Anijit Sarkar · 0 Read more »
By implementing an interface Serializable in the class whose instances are to be serialized.Then passing the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.
Example:
Now, we will see a practical implementation of serialization on an object and we will store the serialized data in a file.
Class SampleClass is a pojo class which implements java.io.Serializable . It contains four String fields, one of which is declared as transient. That means, we can't serialized this field.
Now, Class SerializeObjectToFile, is used to create an object of SampleClass with some values.
Then we serialized that object to a file name sampleClass.ser.
Class SerializeObjectToFile :
Now, to deserialize this data back to an object please check the post Deserializing an Object from File
by Anijit Sarkar · 3 Read more »
Monday, 16 January 2012
Monday, 16 January 2012 by Anijit Sarkar · 0 Read more »
by Anijit Sarkar · 2 Read more »
by Anijit Sarkar · 3 Read more »
by Anijit Sarkar · 1 Read more »
Sunday, 15 January 2012
short j = i; //Implicit casting
Sunday, 15 January 2012 by Anijit Sarkar · 1 Read more »
by Anijit Sarkar · 2 Read more »
by Anijit Sarkar · 0 Read more »
by Anijit Sarkar · 13 Read more »
- A final class can't be extended ie., final class may not be subclassed.
- A final method can't be overridden when its class is inherited.
- You can't change value of a final variable (is a constant).
by Anijit Sarkar · 1 Read more »
by Anijit Sarkar · 5 Read more »
by Anijit Sarkar · 8 Read more »
Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.
Iterators differ from enumerations in two ways:
|
by Anijit Sarkar · 1 Read more »
by Anijit Sarkar · 0 Read more »
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
by Anijit Sarkar · 1 Read more »
- The global variables breaks the referential transparency
- Global variables creates collisions in namespace.
by Anijit Sarkar · 2 Read more »
by Anijit Sarkar · 24 Read more »
by Anijit Sarkar · 2 Read more »
by Anijit Sarkar · 0 Read more »
2. Extending the thread will give you simple code structure in comparison to Runnable Interface.
3. Using Runnable Interface, you can run class several times whereas Thread have the start() method that can be called only once.
by Anijit Sarkar · 0 Read more »
- By implementing runnable interface.
- By extending the Thread class.
by Anijit Sarkar · 9 Read more »
An application programming interface (API) is a library of functions that Java provides for programmers for common tasks like file transfer, networking, and data structures.
List of Java APIs:
There are three types of APIs in Java.- the official core Java API, contained in the JDK or JRE, of one of the editions of the Java Platform. The three editions of the Java Platform are Java ME (Micro edition), Java SE (Standard edition), and Java EE (Enterprise edition).
- optional official APIs that can be downloaded separately. The specification of these APIs are defined according to a Java Specification Request (JSR), and sometimes some of these APIs are later included in the core APIs of the platform (the most notable example of this kind is Swing).
- unofficial APIs, developed by third parties, but not related to any JSRs.
by Anijit Sarkar · 2 Read more »
How to achieve synchronization in java?
In java, synchronization can be achieved by using the synchronized keyword.
by Anijit Sarkar · 28 Read more »
Popular Posts
-
public - public means everyone can access it.That means it's in global scope. As, main method is called by JVM [ Java Virtual Machine...
-
throw is used to throw an exception in a program, explicitly . Whereas, throws is included in the method's declaration part, wi...
-
Singleton in one of the most popular yet controversial design pattern, in the world of object oriented programming. It's one of t...
-
Web Container / Servlet Container / Servlet Engine : In J2EE Architecture , a web container (also known as servlet container or ser...
-
Program compiles. But at runtime throws an error “NoSuchMethodError”.
-
Vector : It's synchronized. It's slower than ArrayList. It's generally used in ...
-
doGet(): protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, java.io.IOException – is a met...
-
In Java Programming Language , we must declare a variable name and type, before using it. The data type of a variable defines the th...