SILCHAR_UNIVE_EXAM_TOP_MCQ
SILCHAR_UNIVE_EXAM_TOP_MCQ
Date :
Pago
DATA TYPES
TYPES AND VARIABLES IN
JAVA
1. Prinzitive Data Types:
Primitive data types are the mast basic types a
data that are predened in Java.
Jhese types represent simple values Such as umbers
and characters.
Exanmple :
22. Arrays
" An Array is a collecton dof variables the
same
locations
type, stored in contiquous memors
Example
int [] mumbers = S1,2,3, 4,53i
string [l names
na ="Alice " " Bob', "Charlie "3;
@
cuTious - pgcammer
cIASSMAte
Date
Page
Example
int age = 25j
String nam : "John"i
( curious
ziOus -- programmer
cIASSMAte
Date :
Page:
32. Conslants :
A CoYstant 1S variable whose value can not
be changed Omce. is asigned.
Comst ants are. declared using the tinal keybard.
Sumlax:
Final <datatype> <constant-name> = <value >;
Example:
tinal int MAX- VALUE =100 i
(@ uriouS--progammer
Fxamples requires
one. 14
Comvering to
Narrouim automaically.
(Manual) : happensIH
Comverting casting
refers
Type Cost4.iTypen1g. 4:
Example Widening ):another.
Example (Automatic lype
int
Casting
i=
10; : a
Casting
double a int In
larger smaller efers
asting
rplicit to Java and
ening @ to long to
Curious data dota ,
înt Converting Type
here
astirg - type type
progcammer oat are Comversion
to to to two one
(int Page: Date :
cIASSMAte
a double. a :
to larger data
smaller types
lomg
me
type
int)
cIASSMAte to t 2nofher.
the
type
(double int
to
:DatePage:
(str)i
Casting changing.
to
cnary"s parseInt
string
l
one
data
typ ways Explicit (@Curious
-progr
ammer
Narrowimg Conversiom
(Narrowing
(widening)
to two -Integer
"123"
refers
Conversion:
in
= di
314 Conversion
Conyersiomdome str
String
(int) variable
from
num
d be Exaaple
= 4.2.
Type Implicit
double
j Can int
int Te
Type
This "
cIASSMAte
Date
Page:
5 Unicode System :
Uricodeis. a character encoding standard that
1S used to represernt texd and symbols in
Java
Erample:
char 1etter ='A; I micocle for 'A' is 65