Chapter : Class as the Basis of All Computation
About Java Programming Language
Topics Covered
- Java: An Introduction
- Java Virtual Machine
- Class Libraries
- Java Character Set
- Tokens
- Keywords
- Identifiers
- Naming Convention of an Identifier
- Literals and its types
- Concepts of Data Types
- Variables
- Reference Types
- Constants
- Operators in Java
- Expressions
- Java Statements
- Significance of Classes
JAVA : AN INTRODUCTION
Java was first developed by James Gosling at Sun Micro systems. It was released in May 1995 as a core component of Sun Micro systems '. Java was basically designed for electrical and electronic appliances for the operation of it remove and touch screen and finally it was found that Java can be used as a Programming language. It is divided into two types of programming
- Java Applications
- Java Applets
The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses.
Java compilers: - Compiler is a program used to compile and run Java program.
Java Virtual Machine:- A Java virtual machine is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java byte code. The J.V.M is detailed by a specification that formally describes what is required in a J.V.M.
Class libraries: - The Java Class Library is a set of dynamically loadable libraries that Java Virtual Machine languages can call at run time. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of the platform-native libraries.
Tokens:-The Java compiler breaks the line of code into text (words) is called Java tokens. These are the smallest element of the Java program.
Keywords:- These are the reserve words used for writing Java code.
Identifiers:- Identifiers are the name given to different parts of the program.
Naming conventions Identifiers :-
1. No Identifier (variable / array / method / class) name should starts with a java keyword.
2. There is no space between an identifiers name.
3. No special characters(such as !@#$%^&*) except _ and $.
4. No identifier should starts with a digit.
Literals and its types:- The physical value which is stored or assign in a variable are literals.
Integer Literal (23,44.44)- The integer values are integer literals
Integer Literal of three types
- Decimal (base 10)
- Octal (base 8)
- Hexadecimal (base 16)
Character Literal (A, B, a, b) - The character values are character literals
Floating Literals (23.43) - The small decimal values are float literals. Floating literal are also called Real literal.
Following are the
Double Literals (23.6889897) - The long decimal values are double literals
Boolean Literals (true,false) - The true-false values are boolean literals
Long Literals (38328236889897) - The long integer values are Long literals
Shot Literals (45) - The shot integer values are shot literals
Byte Literals (3) - The byte integer values are byte literals
Sizes and values that can be stored in the variable can be specifies through data types.
There are two types of data types in Java:
1. Primitive data types: The primitive data types include
- int it helps to define integer data(2, 3, 4, -1, -4, -7 etc). Ex int x=10;
- char it helps to define character data(a, b, %, @, %, * etc).
- float (23.43F, 3.33F etc).
- short(22, 34, 44)
- long(38829239392398L, 39990284884998949L)
- boolean(true, false)
- byte(3, 4, 4, 3 etc)
Array: A collection set of similar values of same type.
Interfaces: A collection of classes.