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

Java Fundamentals Part-1

Uploaded by

vineelap742
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Java Fundamentals Part-1

Uploaded by

vineelap742
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Java By Venkatesh Mansani Naresh i Technologies

Java Fundamentals
Java:
Java is a programming language, platform & technology.
Java is called as programming language because by using Java we can
write programs.

Platform:
It can be a software or hardware environment in which program runs.
C compiler converts unicode into bit code whereas Java
compiler converts unicode into byte code.
JVM:
JVM stands for Java Virtual Machine. It contains interpreter which
converts byte code into bit code.
Both compiler & interpreter are called translation softwares.
Differences between compiler & interpreter:
Compiler converts the whole program at a time whereas interpreter
converts line by line.
Compiler will produce the file whereas interpreter does not produce
the file.
C is a platform dependent whereas Java is a platform
independent.
Java is called as platform independent because programs
written in Java language can be executed on any platform.

venkatesh.mansani@yahoo.com Naresh i Technologies


Java By Venkatesh Mansani Naresh i Technologies

Java Virtual Machine(JVM) is not a platform independent


because windows jvm for windows only, linux jvm for linux
only, solaries jvm for solaries only, .. etc.,
C library included in C program at compile time whereas Java library
included in Java program at runtime.
Java library is called as Java API(Application Programming Interface)
because Java library is an interface between application &
programming language.
Java API is a part of JRE(Java Runtime Environment).
JRE contains JVM(Java Virtual Machine) & Java API(Application
Programming Interface).JRE is a part of JDK(Java Development Kit).
JDK is called as Java software. Latest version of JDK is 21.
In 1995 Java was developed by James Gosling, Patrick Naughton, Ed
Frank, Chris Warth& Mike Sheridan at Sun Microsystems(now owned
by Oracle Corporation).
Java slogan is “Write Once, Run Anywhere(WORA)”

Identifiers:
Identifier is a word and it is used to identify variables, methods, classes,
interfaces, packages, .. etc.,
Identifier can be a variable name, method name, class name, interface
name, package name, .. etc.,

Rules to declare an identifier:


1) It can be formed by using alphabets(A to Z & a to z), digits(0 to 9),
underscore symbol(_) and dollar symbol($).

venkatesh.mansani@yahoo.com Naresh i Technologies


Java By Venkatesh Mansani Naresh i Technologies

2) It must begins with alphabet, underscore symbol(_) or dollar


symbol($).
3) The length of the identifier is not limited.
4) It should not contain special symbol other than underscore &
dollar symbols.
5) It should not contain white space characters(Space bar, tab &
enter keys).

Examples:
1) demo => Valid
2) Demo => Valid
3) DEMO => Valid
4) 2ndDemo => Not Valid
5) Demo2 => Valid
6) version#2 => Not Valid
7) version$2 => Valid
8) version_2 => Valid
9) version-2 => Not Valid
10) _5_ => Valid
11) _$2 => Valid
12) $_2 => Valid
13) 5_$ => Not Valid

Keywords:
A set of words reserved by language itself and those words are called
keywords.

Examples:
int, char, float, double, if, else, while, for, do, private, protected, public,
static, final, void, assert, enum, class, interface, package, ..etc.,

venkatesh.mansani@yahoo.com Naresh i Technologies


Java By Venkatesh Mansani Naresh i Technologies

All keywords must be written in lowercase letters only.


strictfp keyword added in JDK 1.2 version in 1998.
assert keyword added in JDK 1.4 version in 2002.
enum keyword added in JDK 1.5 version in 2004.
Note1: const &goto keywords presently not in use.
Note2: Keyword cannot be used as an identifier.

Literals:
A literal is a source code representation of a fixed value.
In Java, literals are divided into 6 categories:
1) Integer Literals:
Examples: 5, 9, 13, 467, 0, -2, -98, -987
2) Floating Point Literals:
Examples: 2.46, 0.08, -2.46, -999.3566
3) Character Literals:
Examples: 'a', 'x', 'A', 'Z', 'c'
4) String Literals:
Examples: "a", "hi", "hello", "welcome"
5) Boolean Literals:
Examples: true, false
6) Object Literal:
Example: null

venkatesh.mansani@yahoo.com Naresh i Technologies


Java By Venkatesh Mansani Naresh i Technologies

Note1: true, false & null are not keywords.


Note2: true, false & null are also cannot be used as an identifier.

Data Types:
A data type that determines what value variable can hold and what are
the operations can performed on variables.
In Java, data types are divided into 2 categories:
1) Primitive Data Types
2) Reference Data Types

1) Primitive Data Types:


Primitive data types are predefined data types and these are named by
keywords. There are 8 primitive data types.
These are divided into 4 sub categories:
1) Integers: byte, short, int, long
2) Floating Point Numbers: float, double
3) Characters: char
4) Boolean: boolean

2) Reference Data Types:


Arrays, Strings, Classes, Interfaces, .. etc.,

Variables:
A variable is a container that contains data.
Declaration:
Syntax: DataType Variable;

venkatesh.mansani@yahoo.com Naresh i Technologies


Java By Venkatesh Mansani Naresh i Technologies

Example: int x;
Assignment:
Syntax: Variable=Literal;
Example: x=10;
Initialization:
Syntax: DataType Variable=Literal;
Example: int x=10;
If the number is out of int range & within long range(long literal) then it
must be suffixed with l or L.
Every float literal must be suffixed with f or F;

ASCII Code: Digits starts with 48, Capital letters starts with 65 &
Small letters starts with 97.

By

Mr. Venkatesh Mansani


Naresh i Technologies
venkatesh.mansani@yahoo.com

venkatesh.mansani@yahoo.com Naresh i Technologies

You might also like