Data Types ...
Java .
Data Types in Java
Primitive data types: Non-primitive data types:
The primitive data types The non-primitive data
include boolean, char, byte, types include Classes,
short, int, long, float and Interfaces, and Arrays.
double.
Q. Why do we need to declare the variable before using it in java?
statically typed programming
Language
.
woul
as
int = 10 5 ; x
·
/ it
boolean b = 0
; X
8
Patatypes
Like
3 Gi
·
Int
Char
·
signed
long
·
·
Double
Byte point
·
Short
Slowing
·
float
Q. Char Datatype can store a single character so why is it of size
2 bytes and what is \U0000?
While using 16 bits for every character may seem like overkill for representing many
characters that only need 8 bits (or even fewer), Java's design emphasizes consistency,
portability, and robust internationalization support. This design decision ensures that Java
can handle text and characters from various languages and character sets without
requiring extensive conversions or adjustments.
It is because java uses Unicode system not ASCII code
system. The \u0000 is the lowest range of Unicode system.
charc
'Al ; ~withmetic
⑭
:
⑮
I
S 0 .
ph (c 1)+
I
, O
1166 on
C 2
.
-
intn=c ; 1165 Cert
"
craw b :
I hard m :
int a :
"A-is' ;
Chart= 65; v
AB 2B
byte- Shoot
uB
testin
↑ int
long > -
float s Double
- VB 8 B YB 8B
Char
4 ?
Tnese] [
Floating-point
In memory is
way
to
represent no ·
So that store the of
diff
no
.
,
can
long
↑ double d = 130 . 456 ;
int = lint)d : //130
byte b =
(byte) & ; 1/-126
= byte b = 100 ,
b = b+ 2 ; Il Error
- -