0% found this document useful (0 votes)
13 views

JAVA

Java by Satish Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

JAVA

Java by Satish Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

JAVA

22 July 2024 20:20

Java : james gosling in 1995 at sun microsystem .Now its owned by Oracle Corporation

-> Java is case sensitive


-> java is a statically typed language[ it means all variables must be declared before they can be used]
-> java is a platform indenndence

Slogan : "Write Once ,Run AnyWhere.

Features of java:
1].enterprise
2]. portable
3].interpreter

Java fundamentals:

Identifier:An identifier is a Word &its used to identify variable,method,interface,package,class,etc...,

eg :
Sammer -> right
3sammer -> Wrong
sameer -> right
3sameer -> Wrong
$sameer -> Right

Rules for identifiers


1. It can be formed by using alphabets(A to z& a to b) ,digits(0 to 9),dollar
symbol($),under score symbol ( _).
2. It must begins with dollar, alphabets,_.
3. There is no limiti for length
4. It should not contain spaces(white Spaces,tabs, enter keys)
5. It should contain only symbols ($, _) it should not contain special symbols.

Examples:
1. Demo
2. Demo
3. 3demo
4. Demo_class
5. $demo
6. _variable_
7. -5$
8. Demp%w
9. 77Demo
10. Demo$variable
11. Sameer10_$variable

Keywords:
New Section 1 Page 1
Keywords:

A set of words reserved by language it self &those words are called keyword

1. abstract
2. assert
3. boolean
4. break
5. byte
6. case
7. catch
8. char
9. class
10. const (reserved, not used)
11. continue
12. default
13. do
14. double
15. else
16. enum
17. extends
18. final
19. finally
20. float
21. for
22. goto (reserved, not used)
23. if
24. implements
25. import
26. instanceof
27. int
28. interface
29. long
30. native
31. new
32. null
33. package
34. private
35. protected
36. public
37. return
38. short
. All keywords shold be in loweer case

Note1: const&goto keywords are not in use now.


2. key words cannot be used as identifiers

Eg: int x=10;

Literals:

A literal Is a source code reperesentation of a fixed value.


New Section 1 Page 2
A literal Is a source code reperesentation of a fixed value.

Eg: x=10;

Literals are diveded into 6 types:

1. Integer or int : 2,33,45,27,72773 etc..,

2. Floating point literals : 0.545,2.345,3.2,56666.0000 etc..,

3. Charcter literals: 'a' ,'w', 'r','3','#'[ use only[ ' ] quote that means char][ for number
quotes not mandatory]

4.String literals : "Sameer","a","134"[ use only double [" "] that means String]

5.Boolean : True , flase

6. Object literal : Null{empty or nothing}

Note1: True ,False are not keywords


Note 2: true & false,Null are also not used as identifiers

DATA TYPES :

A data type that determine what value variable can hold & what are the operations can
be performed on variable

They are two of Data Types:


1. Primitive data type
2. Reference Data Type

Primitive data type:

All pd are pre-defined data types & these are named by keywords

These are eight Primitive data types & divided into 4 categories
1. Int or integer
2. Floating
3. Char or character
4. Booleans

Int or integer:

Data types Memory size range


Byte 8 bits(1 byte) -2^7 to 2^7-1
short 16 bits (2 bytes)
New Section 1 Page 3
short 16 bits (2 bytes)
int 32 bits(4 bytes)
Long 64 bits(8 bytes)

Floating :

Data types Memory size


float 32bits(4 bytes)
Double 64 bits(8 bytes)

Memory size :

Data type memory size


char 16bits(2 bytes)

Booleans :

DATA types memory size range


boolean 1 bits True(1)/ false(0)

ASCII: American Standard code for information interchange

48=0 65=A 97=a


49=1 66=B 98=b
50=2 67=C
51=3
.
.
.
.59=9 90=Z

Float a= 23.4; ---> 23.5f


Float b=546.00;
Double c= 243.773;
Char n='A';
Boolean=true;
String="HI";
Char n=43;

Eg:
int a='A';
int b=a;
New Section 1 Page 4
int b=a;
System.out.println(a);

1.Boolean a= true;
Int b=a;
System.out.println(b);

2.char a='a';
char b='A';
Int c=a+b;
System.out.println(c);

New Section 1 Page 5

You might also like