ARIANE 4 : Was crashed because of datatype storage // (float to Integer )
Byte : It is JVM dependent n the kind of OS on which JVM is installed and t and we cant say that it is 1 bit
DATATYPE DEFAULT BITS
Byte 0 1
Short 0 2
Integer 0 4
Long 0 8
float decimal 0 4
double decimal 0 8
char \u0000' 2
Boolean FALSE JVM
TYPE CONVERSION :
ByteshortIntlong (Its done implicitly by JVM)
Byteshortintlong(It is done by explicit casting ) this is not done implicitly and its also called
narrowing conversion
U need to say to JVM to do so and ther might b a loss of data
Floatdouble(Implicit) viveversa is explicit
Boolean datatype cannot be casted
NOTE: If the two types r compatible then java will do conversions automatically like from byte to long
and vv
If they are incompatible then also its still possible to make conversion by type casting
The numeric types r not compatible with car or Boolean and also char and Boolean are not compatible
with each other.
Ex:
Short c = 234;
Byte d=(byte)c;
The Negative number is stored with 2’s complement
--JAVA automatically promotes each byte or short operand to int whwn evaluating any expressions
Java uses 2’s complent to store negative numbers
CONDITIONAL OPERATORS :
== operator will compare the bit pattern of primitive datatypes
Ex: a=10, b=10
If(a==b)
== operators in case of object will not compare the contents of object rather it will compare the
memory address, to compare contens u can use equals operator
Ex:
Car c = new Car()
Car b=c;
If(b=c) it returns true as d my & is compared
instanceof operator
Used 2 find if the reference is an instance of a class type
Class car implements vehicle
Car c=new Car();
If(c instanceof Vehicle) true
If(c instanceof Car) true
Both of them returns true
Short Circuit AND(&&) and OR(|| )
Unsigned right shift operator:
Very similar to right shift operator
If the MSB is 1 its replaced with 0
Even negativw numbers becomes positive with this operator
CONSTRUCTOR: Initialises variable as soon as u create d object.
Its special type of method it
dosent have return type.
CTRL + C is the ascii character ETX which tells it is the END of TEXT and tells the program to halt.
Details of font.
To compile all files in current dir use > javac *.java
--JAVA CODE
Getters : methods 2 return class fields values
Setters : methods 2 set class fields values
This = the current object
Class consisits of fields, methods, constructor
Members= fields, methods of class
All java classes are subclasses of Object class