0% found this document useful (0 votes)
25 views19 pages

Concepts and Datatypes - Theory

The document discusses various data types and values in Java, including character sets, Unicode, ASCII, and escape sequences. It outlines the types of tokens in Java, such as literals, identifiers, operators, separators, punctuators, and keywords, as well as primitive and non-primitive data types. Additionally, it covers expressions, type conversion, coercion, and type casting in Java programming.

Uploaded by

Parshveer Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views19 pages

Concepts and Datatypes - Theory

The document discusses various data types and values in Java, including character sets, Unicode, ASCII, and escape sequences. It outlines the types of tokens in Java, such as literals, identifiers, operators, separators, punctuators, and keywords, as well as primitive and non-primitive data types. Additionally, it covers expressions, type conversion, coercion, and type casting in Java programming.

Uploaded by

Parshveer Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

VALUES AND DATA TYPES

- Roopesh Saigaonkar

VALUES AND DATA TYPES


• Different Character set used in Java
– Letters
– Digits
– Operators
– Delimiters
- Roopesh Saigaonkar
UNICODE
• It is standard encoding system which encodes a character of any computer language

UNICODE ADVANTAGE
• Universal coadding scheme
• Coadding is unique so one code will never be given to more than one character
- Roopesh Saigaonkar
ASCII CHARACTERS
A M ER ICAN STA NDA R D CO DE FO R I NFO R M ATI ON I NT ER CH A NG E

• A – Z : 65-90
• a – z : 97-122
• 0 -9 : 48 -57
• Spacebar : 32
- Roopesh Saigaonkar
UNICODE VS ASCII

UNICODE ASCII
Coadding scheme for numerous characters of Coadding scheme for limited characters
different scripts
It Ranges from 0x0000 upto 0xFFFF if is 16-bits It’s range is only 7 binary bits that is 128 characters
(aprox ; 1,60,755 characters) from 0-127
- Roopesh Saigaonkar
ESCAPE SEQUENCE
• non graphic characters, which are used as commands to direct the
cursor while printing

1. \t tab space 2. \v vertical tab


3. \’ 4. \”
5. \n new line feed 6. \\
System.out.print(“Tanmay \v Advait\\Hemang”);
Tanmay

Advait\Hemang
- Roopesh Saigaonkar
TOKENS

• Each individual component used in Java is called as token.

Eg int a = b + 5 ;
- Roopesh Saigaonkar

5 TOKENS AVAILABLE IN JAVA

•Literals
•Identifier
•Operators
•Separator and Punctuators
•Keywords
- Roopesh Saigaonkar
LITERALS
Defination : Constants used in Java, which remains fixed trough out the program

• Integer literal : nos. without decimal points eg 14, 10,-16 etc


• Real Literal : nos. with decimal points eg 24.56, 32.66 etc
• Character Literal : Alphanumeric in nature eg ‘A’ , ‘a’, ‘2’
• String Literal : Set of Alphanumeric characters eg “COMPUTER APP”
• Boolean Literal : Special literal represent true or false
• Null literal : Used in string (not in portion)
- Roopesh Saigaonkar
IDENTIFIER
Defination : It represent program elements. A variable name , function name , class name are
termed as identifier which is named memory location.

Eg int a = 10; where a is identifier


- Roopesh Saigaonkar
OPERATORS

• Arithmetical operator : + - * / %
• Relational Operator : > < >= <= = = !=
• Logical Operator : && || !
• Assingment Operator :=
• Unary , Binary , Ternary (Studied Further in details )
- Roopesh Saigaonkar

SEPARATORS AND PUNCTUATORS


Special characters used in Java
• Separators : ( ,) { ,} [ ,]
• Punctuators: ? . ;
- Roopesh Saigaonkar
KEYWORDS
• Java reserved word is called as keyword which carry special meaning to the
system compiler.
Eg : int, void ,import etc
- Roopesh Saigaonkar
DATA TYPES IN JAVA
Data Byte Default
Type size values
• boolean 1 byte false
• byte 1 byte 0
• char 2 bytes ‘\u0000’
• short 2 bytes 0
• int 4 bytes 0 Primitive Data Type
• long 8 bytes 0L
• float 4 bytes 0.0f
• double 8 bytes 0.0d/0.0
• String no of characters null/ “”
X 2bytes

Array, Classes , Objects etc


Non- Primitive Data Type
- Roopesh Saigaonkar
Primitive Non-Primitive
Independent of any Dependent on
other data type Primitive data type

Basic data type Composite Data type

Inbuilt data type Derived Data type


Eg : int, byte,long etc Eg : String, Array,
Classes
TYPES OF EXPRESSION

•2+4= 6
•2.5+2.5=5.0
•2+2.0=4.0
- Roopesh Saigaonkar
TYPES OF EXPRESSION
Mixed Pure Expression
Expression with more Expression with one data
than one data type type
Type conversion takes Pure expression doesn’t
place fallow type conversion
int a=5; int a=5;
float b=10.0f; int b=10;
System.out.println(a+b); System.out.println(a+b);

Output : 15.0; Output : 15;


- Roopesh Saigaonkar
TYPE CONVERSION
• . In a mixed expression , conversion of data type into particular data type is called as type
conversion. They are of two type Implicit and Explicit type conversion

• Examples
2 + 3.5f = 5.5 //mixed float
2.5f+ 2.0=4.5 //mixed double

(int)2.5f+ (int)2.0=4

2+(int)2.5=4
- Roopesh Saigaonkar
TYPES OF EXPRESSION
Coercion Type casting
Also called implicit type Also called as explicit type
conversion conversion
Automatic conversion to Manual conversion of
higher data type particular data type
It is done automatic Needs users intervention
int a=5; int a=5;
float b=10.0f; float b=10.0f;
System.out.println(a+b); System.out.println((int)(a+b));

Output : 15.0; Output : 15;

You might also like