It2EDU

Sunday, December 25, 2016









Java Primitive data Types and its Ranges:


































































Data Type



Size/Width



Range



Group



Byte



8-bits



-128 to 127  (-28
to 28-1)



 Integer Group



Short



16-bits



-32768 to 32767  (-216
to 216-1)



Int



32-bits



–2,147,483,648
to 2,147,483,647


  (-232 to 232-1)



Long



64-bits



–9,223,372,036,854,775,808 to
9,223,372,036,854,775,807


(-264 to 264-1)



Float



32-bits



1.4e–045
to 3.4e+038



Floating point



Double



64-bits



4.9e–324
to 1.8e+308



Char



16-bits



216   \u0000 to \uFFFF



Character



Boolean



1-bit



20
True or false



Boolean












When a Java program is
compiled it is converted to byte code which is then executed by the Java
interpreter by translating the byte code into machine instructions. Java
interpreter is part of Java runtime environment.  Byte code is an intermediate code independent
of any machine and any operating system. 
Program in Java run time environment, which is used to interpret byte
code, is called Java Virtual Machine (JVM). 
The Java compiler reads Java language source files, translates the
source into Java byte codes, and places the byte codes into class files. 





Any machine for which Java
interpreter is available can execute this byte code. That’s why Java is called Machine
independent and Architecture neutral
. Below Figure shows that Java
compiler is accepting a Java program and producing its byte code. This byte code
can be executed on any operating system (Window-98, Macintosh, Linux etc.) running
on any machine with suitable Java interpreter of that machine. The JVM plays
the main role to making Java portable. It provides a layer of abstraction
between the compiled Java program and the hardware platform and operating system. The JVM is
central to Java’s portability because compiled Java programs run on the JVM,
independent of whatever hardware is used.







java virtual machine
Java Virtual Machine











Tuesday, December 20, 2016









Data Structures – Queue:





A Queue is a collection or abstract data type  or linear data structure, in which  the first element is inserted from one end
called REAR (also called tail), and the deletion of existing element
takes place from the other end called as FRONT(also called head). This
makes queue as FIFO data structure, which means that element inserted first
will also be removed first. 





Adding of an element to the queue is Enqueue.





Removing of an element from the queue is Dequeue.





The queue retrieval operations — poll, remove,
peek,
and element — access the
element at the head of the queue. The head of the queue is the least element with respect to
the specified ordering. If multiple elements are tied for least value, the head
is one of those elements; ties are broken arbitrarily.












Queue follow First In First
Out. In a FIFO data structure, the
first element added to the queue will be the first one to be removed. This is
equivalent to the requirement that once a new element is added, all elements
that were added before have to be removed before the new element can be
removed. A peek or front
operation is entered and returning without dequeuing it(Removing it).




Implementation of Queue:

 

 Theoretically,
one characteristic of a queue is that it does not have a specific capacity.
Regardless of how many elements are already contained, a new element can always
be added. It can also be empty, at which point removing an element will be
impossible until a new element has been added again.






Fixed length
arrays are limited in capacity, but it is not true that items need to be copied
towards the head of the queue. The simple trick of turning the array into a
closed circle and letting the head and tail drift around endlessly in that
circle makes it unnecessary to ever move items stored in the array. If n is the
size of the array, then computing indices modulo n will turn the array into a
circle. This is still the conceptually simplest way to construct a queue in a
high level language, but it does admittedly slow things down a little, because
the array indices must be compared to zero and the array size, which is
comparable to the time taken to check whether an array index is out of bounds,
which some languages do, but this will certainly be the method of choice for a
quick and dirty implementation, or for any high level language that does not
have pointer syntax. The array size must be declared ahead of time, but some
implementations simply double the declared array size when overflow occurs