Download - Java basic introduction
IDEAL EYES BUSINESS COLLEGEA
PRESENTATION
1UPLOADED BY:- VIVEK KUMAR
2
DEVELOPER OF JAVA:- JAMES GOSLING
1991 1995 2009
1991 2010 2014 STIL..
HISTORY OF JAVA Java Is A Object Oriented Programming Language
Developed By James Gosling In Year 1991. Java, May 20, 1995, Sun World. Originally Language Name Oak. It Said To Be The Name Java Is Come From Several
Individuals Involved In This Project James Gosling , Arthur , Van Goff And Andy Bechto Lsheim.
Name Changed To Java.
HISTORY OF JAVA Java is popular and powerful language. The java language was derived from c++ Much of the syntax in java is similar to c and
c++. Java does not have pointer features. Java supports WORA concept means write once,
run anywhere. First Public Release In 1995.
5
HISTORY OF JAVA Java is high level language that looks
very similar to c and c++ but offers many unique features of its own.
6
WHERE JAVA IS USED ?� According to sun, 3 billions devices run on
java. There are many devices where java is currently used some of them are as :-
� Desktops � Web � Mobile
7
Embedded system Smart card RoboticsGames
DESKTOP
8
WEB
9
MOBILE PHONES
10
EMBEDDED SYSTEM
11
SMART CARD
12
ROBOTICS
13
GAMES
14
FEATURES OF JAVA
Java is simple
Java is object-oriented
Java is platform independent
Java is distributed
Java is interpreted
Java is robust15
FEATURES OF JAVA Java is secure
Java is architecture-neutral
Java is portable
High performance
Java is multithreaded
Java is dynamic16
WHY JAVA IS SIMPLE ?1. Syntax is based upon c++.
2. Removed many confusing and lorrarely used features (explicit pointer,operator overloding).
3. No need to remove unreferenced objects because there is automatic grabage collection in java.
17
WHAT IS OBJECT ORIENTED?
� Object oriented means we organize our software as a combination of different types of object that incorporates both data and behavior.
� It is methodology that simplify software development and maintenance by providing some rules.
� We can do program with the help of object
18
iding
BASIC CONCEPT OF OPPSBasic concept of OPPS are:-1.Objects2.Class3.Inheritance4.Abstraction5.Encapsulation6.Polymorphism7.Data hiding
19
WHY JAVA IS PLATFORM INDEPENDENT?
What is platform? A platform is the hardware and software environment in which programs runs.Java is platform independent because its byte code can be run on multiple platforms.Like as:- windows, Linux, Unix, sun Solaris, Mac/OS etc.That is write onces and run anywhere (WORA).
20
WHY JAVA IS MORE SECURED ?1. Java is more secure because no explicit pointer use in java.2. Programs run inside the virtual machine sandbox.3. Class loader adds security by separating the package for the
classes of the local file system from those that are imported from network sources.
4. Byte code verifier checks the code fragments for illegal code that can violate access right to object.
5. Some security can also provided by application developer through SSL, JAAS, cryptography etc.
21
ROBUSTRobust simply means error tolerance . java uses strong memory management . There are lack of pointer that avoids security problems. There is automatic garbage collection in java . There is exception handling and type checking mechanism in java. All these pointer makes java robust .
22
ARCHITECTURAL NATURAL
There is no implementation dependent features its means it is independent of any hardware configuration.
23
PORTABLEWe may carry the java byte code to any platform very easily.
HIGH PERFORMANCE
Java is better and faster than traditional interpretation since byte code is “close” to native code still some what slower than a complied language like c++.
24
DISTRIBUTEDWe can create distributed application in java. RMI and EJB are used for creating distributed application. We may access files by calling the methods from any machine on the internet.
25
MULTITHEADEDA Thread Is Like A Separate Program Executing, Concurrently. We Can Write java program that deal with many tasks at once by defining multiple threads. The main advantage of multithreading is that it shares the same memory. Threads are important for multimedia ,web application etc.
26
CREATING “HELLO JAVA” PROGRAMMING EXAMPLE.
Class simple{public static void main(String args[]) { System.out.println(“hello java”); }}
27
Save this file as simple.java.To compile javac simple.javaTo execution(run time) java simpleOutput hello java.
28
CLASSThe classis the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. The mystery of the class will continue to be unveiled throughout this book. For now, though, understand that a program is defined by using one or more classes.
29
WHAT IS STATIC?Static is a keyword, if we declare any method (function) as static ,it is known as static method. The core advantage of static method is that there Is no need to create object to invoke the static method. The main method is executed by the JVM so it doesn’t require to create object to invoke the main method ,so it saves memory.
30
ct to
VOID & STRING ARGS[]
Void is the return type method (function) . It means it doesn’t return any values.Main represent startup of the program.String args[] is used command line argument.System.out.println()It is used for print the statement.
31
HOW TO SET PATH OF JDK IN WINDOWS
Path is required for using tools such as javac.java etc. if you are saving the java file in jdk/bin folder, path is not required but if you are having your java file outside the JDK/bin folder. It is necessary to set path JDK. There are two ways to set path of JDK. 1.Temporary2.permanently
32
SETTING OF TEMPORARY PATH
For setting the temporary of JDK, you need to follow these steps:-1.Open command prompt2.Copy the path of bin folder3.Write in command prompt 4. Set path= copied path c:\program\files\java\jdk 1.7.0 25\bin;.;
33
JAVA PROGRAM� public class testrrr� {� public static void main (String args[])� {� for(int i=0,j=10;i<10;i++,j++)� {� System.out.println(i+" "+j);� }� }� }
34
35
OUTPUT WOULD BE
1. 36
1. public class classA2. {3. public int getValue()4. {5. int value=0;6. boolean setting = false;7. String title="hello";8. if(setting && title == "hello")9. {10. System.out.println("first if
condition");11. return 1;12. }13. if(value == 1 &&
title.equals("hello"))14. {15. System.out.println("second if
condition");16. return 2;17. }
18. return 5;19. }20. public static void main(String args[])21. {22. classA a= new classA();23. int y=a.getValue();24. System.out.println("value of y is"+y);25. }26. }
37
OUTPUT WOULD BE
38
interface DeclareStuff{public static final int EASY =3;void doStuff(int t);}public class TestDeclare implements DeclareStuff{public static void main(String args[]){int x = 5;new TestDeclare().doStuff(++x);}public void doStuff(int s){s += EASY - ++s;System.out.println("s"+--s);}}
39
OUTPUT WOULD BE
40
class c{public static void main (String args[]){int x=9;if(x == 9){int x=8;System.out.println(x);}}}
41
OUTPUT WOULD BE
42
class A{A(){System.out.println("A class constructor");}{System.out.println("annonymous block in class A");}void display(){System.out.println("display in class A");}}class B extends A{B(){System.out.println("B class constructor");}{System.out.println("annonymous block in class B");}void display(){System.out.println("display in class B");}}class C extends B{C(){System.out.println("C class constructor");}{System.out.println("annonymous block in class c");}void display(){System.out.println("display in class C");}}
class D extends C{D(){System.out.println("D class constructor");}{System.out.println("annonymous block in class D");}void display(){System.out.println("display in class D");}
public static void main(String args[]){C c1=new C();c1.display();}}
43
OUTPUT WOULD BE
44
class jump_statments{public static void main(String args[]){int x=2;int y=0;for(;y<10;++y){if(y%x==0)continue;else if(y==8)break;elseSystem.out.println(y+" ");}}}
45
OUTPUT WOULD BE
46
class output_test{public static void main(String args[]){int x,y=1;x=10;if (x!=10 && x/0 ==0)System.out.println(y);elseSystem.out.println(++y);}}
47
OUTPUT WOULD BE
DON’T TRY TO LEARN JAVA JUST TRY TO LIVE
IT..THANK YOU
48