In InputStream class of the java.io.* package :
int read() throws IOException
read() returns a byte as it is under the bytestream class, but it is stored in integer ,without any error.
Why is it so ?? and how is it happening. Help me the memory allocation design also
You can up-cast freely (from a primitive that uses less bytes to one that uses more bytes), because you loose no information (you can put a small thing in a large container).
It is only when you down-cast (from a primitive that uses more bytes to one that uses less bytes) that you must explicitly cast (when you put a large thing in a small container, you risk chopping some of the thing off to make it fit)