Java
Java
Introduction
Program : is Nothing but a group of
statements to perform a particular task. For writing the program , corresponding language is required. Languages are 3 types: 1.programming languages 2.Scripting languages 3.Markup languages
Introduction
Low Level Very difficult to
Middle Level
High level
reading,writing,debuggi ng etc(ex:Binary language) Difficult to reading,writing,debuggi ng etc(ex:Assembly language) Easy to reading,writing,debuggi ng(ex:c,c++,java)
->These are composed of Simple,hierarchical flow structures. These are sequence, selection, and repetition. ->The above steps are difficult to follow and to maintain.(ex:C) Object Based Languages ->These will support the object oriented features Abstraction and encapsulation.(not polymorphism and Inheritence are not supported)(ex:VB ,javascript) Object Oriented Languages -> These will support the object oriented features abstraction,encapsulation,inheritence and polymorphism. (java,smalltalk,c++)
Objects are 2 two kinds. Real Life Objects : Which are physically existing Software objects: Exists only within the memory. These are created for the real life applications. If an entity can satisfy 3 conditions , then it is called as an object. -> State: It is nothing but part of the object . It is recognized as a variable in the programming language. It is not constant.
->Objects are independent. -> Modifications can be done easily. ->Code reusability. o 4 principles I. Abstraction II. Encapsulation III. Inheritance IV. Polymorphism Any language will supports above 4 principles , that language called as Object Oriented Language.
Java Introduction
Java is an OOL. Java is a fully OOL. java is not pure OOL by default . By
adding wrapper classes , it is becoming as a pure OOL. Java is strictly typed language. Java programs are one time creation and no.of times execution(WORE/WORA)
Features of Java
Simple language OOL Platform Independent Robust Secure
Multithreaded
Architectural Neutral Distributed language
Dynamic language
History of Java
James Gosling is called the father of java Developed by SUN Microsystems(green team) First name is OAK Logo coffee bean Moscot Duke First time tested on Solaris SPARC First browser supported is Netscape Navigator Java has it own browser called Hot Java It is an open source software
Year
Version
Code Name -
New Features All are new Inner classes,Swing are introduced and Improved the AWT Rebirth of java. JFC , UI , Collections
palygrou 59P,1520C nd
2000 J2sdk1.3
2002 J2sdk1.4 2004 J2sdk1.5
kestral
Merlin Tiger
76P,1842C
HotSpot JVM
135P,2991C Assertions , logging facility in java.io 165P,3000C Revolutionary one . (more ) Autoboxing , templates etc are introduced.
J2sdk1.6
Mustang
Introduction
Java Categories Standard Edition
->Small Applications ->Middle Applications Enterprise Edition ->Enterprise Applications Micro Edition ->Mobile Applications
Architecture
JDK-Java Development Kit
JRE-Java Runtime Environment JVM-Java Virtual Machine JDK Tools=JRE +JVM JRE = RunTime Libraries +JVM
JDK Tools
When Java is installed , the following folders are created. bin , Demo , include , jre and lib Bin-contains executable files Some JDK Tools are javac , javap , java , jdb , javah , jarsigner , appletviewer , keytool , jar , javadoc Javac-It is used to compile the java programs Javac filename.java ->During compilation , to see what is happening then use verbose ex: javac verbose filename.java ->To compile more file javac @abc ->It will translate the java code into byte code .java -> .class
JDK Tools
Java : It will convert the .class file into .exe
->It is also called as java executor ex: java filename Javap : It is also called as java profiler Used to find out the details of the class ex : javap filename javap java.lang.Thread Javadoc : It is help file javap filename.java
JVM
It is a software used to convert the byte code into
machine code. It is specific to operating system. Each and every OS , separate JVM is available. ->Byte code and Binary code both are not same. ->Binary code means executable code or machine code. ->Byte code is an intermediate code . It is executed directly . It is executed by JVM.
Java Tokens
Token is a smallest individual unit.
Every statement is a combination of tokens. Tokens are
->Whitespaces (blank /spacebar/tab) ->Identifiers(variables) Used to identify the memory location ->Comments These are not recognized by compiler. Provides description of the program.
Java Tokens
3 types i)Single line c style (/*-----*/) c ++ style (//) ii)Multiline/paragraph (/* -------------*/) iii)HTML/Document (/**--------------*/)
Java Tokens
Separator : Used to separate the statements
[] array initialization {} block statements/ array initialization () function declaration , - separation of variables ; - end of the statement Literals _______________________________ Integer float character booolean String
Java Tokens
Operators : Used to perform an opearation
Unary one operand ( +x , -x) Binary Two operands (x+y,x-y) Ternary 3 operands (a>b ? T : F) Arithmetic : + , - , / , % Logical : boolean(T/F) logical AND - & logical OR - | logical not - ! Conditional AND - && Conditional OR - ||
Java Tokens
Negation - ~ Assignment i = i + 2
i+ =2 Comparison - == Conditional -> new : memory allocation operator ->(type) : casting -> instance of - used to findout the corresponding object is belongs to the class or not
Java Tokens
Truth table for logical operators
x T T y T F !x F F X&y X&& y T F X|y X || y T T X xor y F T
F
F
T
F
T
T
F
T
T
F
T
F
Java Tokens
& - Event though first condition is false, it will
check for the second. && - If first condition is true then only control goes to next condition otherwise second condition not checked Keywords : All are predefined and should be use them as a variable. Statements : Tokens are grouped together to form a statement.
Java Tokens
Statement Expression ->Assignment ->Memory allocation ->Method call ->Preincrement/postIncrement ->predecrement/postdecrement Selection ->Conditional - if else , switch case ->Iterative - do while , while , for ->Transfer/jump - break , continue , return
Java Tokens
Syncronized Safeguard statements -contains try-catch