Java 1[1].pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Introduction to Java programming Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language that has a particular syntax and style. A Java platform is a particular environment in which Java programming language applications r...

Introduction to Java programming Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language that has a particular syntax and style. A Java platform is a particular environment in which Java programming language applications run. History of Java 1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team. 2) Initially designed for small, embedded systems in electronic appliances like set-top boxes. 3.Firstly, it was called "Greentalk" by James Gosling, and the file extension was.gt. 4) After that, it was called Oak and was developed as a part of the Green project. 5) In 1995, Oak was renamed as "Java" because it was already a trademark by Oak Technologies. 6) Notice that Java is just a name, not an acronym. 7) Initially developed by James Gosling at Sun Microsystems 8) In 1995, Time magazine called Java one of the Ten Best Products of 1995. 12) JDK 1.0 released in(January 23, 1996). After the first release of Java, there have been many additional features added to the language. Now Java is being used in Windows applications, Web applications, enterprise applications, mobile applications, cards, etc. Each new version adds the new features in Java. The Java Programming Language Platforms There are four platforms of the Java programming language: Java Platform, Standard Edition (Java SE) Java Platform, Enterprise Edition (Java EE) Java Platform, Micro Edition (Java ME) JavaFX All Java platforms consist of a Java Virtual Machine (VM) and an application programming interface (API). The Java Virtual Machine is a program, for a particular hardware and software platform, that runs Java technology applications. An API is a collection of software components that you can use to create other software components or applications. Each Java platform provides a virtual machine and an API, and this allows applications written for that platform to run on any compatible system with all the advantages of the Java programming language: platform-independence, power, stability, ease-of- development, and security. Java SE Java SE's API provides the core functionality of the Java programming language. It defines everything from the basic types and objects of the Java programming language to high-level classes that are used for networking, security, database access, graphical user interface (GUI) development, and XML parsing. In addition to the core API, the Java SE platform consists of a virtual machine, development tools, deployment technologies, and other class libraries and toolkits commonly used in Java technology applications. Java EE The Java EE platform is built on top of the Java SE platform. The Java EE platform provides an API and runtime environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure network applications. Java ME The Java ME platform provides an API and a small- footprint virtual machine for running Java programming language applications on small devices, like mobile phones. The API is a subset of the Java SE API, along with special class libraries useful for small device application development. Java ME applications are often clients of Java EE platform services. JavaFX (Java "special EFF-ECTS") JavaFX is a platform for creating rich internet applications using a lightweight user-interface API. JavaFX applications use hardware-accelerated graphics and media engines to take advantage of higher-performance clients. JavaFX applications may be clients of Java EE platform services. Java Version History Many java versions have been released till now. The current stable release of Java is Java SE 10. 1. JDK Alpha and Beta (1995) 2. JDK 1.0 (23rd Jan 1996) 3. JDK 1.1 (19th Feb 1997) 4. J2SE 1.2 (8th Dec 1998) 5. J2SE 1.3 (8th May 2000) 6. J2SE 1.4 (6th Feb 2002) 7. J2SE 5.0 (30th Sep 2004) 8. Java SE 6 (11th Dec 2006) 9. Java SE 7 (28th July 2011) 10. Java SE 8 (18th Mar 2014) 11. Java SE 9 (21st Sep 2017) 12. Java SE 10 (20th Mar 2018) Features of Java The primary objective of Java programming language creation was to make it portable, simple and secure programming language. The features of Java are also known as java buzzwords. 1. Simple 2. Object-Oriented 3. Portable 4. Platform independent 5. Secured 6. Robust 7. Architecture neutral 8. Interpreted 9. High Performance 10. Multithreaded 11. Distributed 12. Dynamic 1.Simple Java is considered as one of simple language because it does not have complex features like Operator overloading, Multiple inheritance, pointers and Explicit memory allocation. Object-oriented Java is an object-oriented programming language. Everything in Java is an object. Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and methods. Basic concepts of OOPs are: 1. Object 2. Class 3. Inheritance 4. Polymorphism 5. Abstraction 6. Encapsulation Platform Independent Java is platform independent because it is different from other languages like C, C++, etc. which are compiled into platform specific machines while Java is a write once, run anywhere language. A platform is the hardware or software environment in which a program runs. There are two types of platforms software- based and hardware-based. Java provides a software-based platform. It has two components: 1. Runtime Environment 2. API(Application Programming Interface) Java code can be run on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac/OS, etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-independent code because it can be run on multiple platforms, i.e., Write Once and Run Anywhere(WORA). Secured Java is best known for its security. With Java, we can develop virus-free systems. Java is secured because: o No explicit pointer o Java Programs run inside a virtual machine sandbox We don’t have pointers and we cannot access out of bound arrays (you get ArrayIndexOutOfBoundsException if you try to do so) in java. That’s why several security flaws like stack corruption or buffer overflow is impossible to exploit in Java. Robust Robust simply means strong. Java is robust because: o It uses strong memory management. o There is a lack of pointers that avoids security problems. o There is automatic garbage collection in java which runs on the Java Virtual Machine to get rid of objects which are not being used by a Java application anymore. o There are exception handling and the type checking mechanism in Java. All these points make Java robust. Architecture-neutral Java is architecture neutral because there are no implementation dependent features, for example, the size of primitive intypes is fixed. In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. However, it occupies 4 bytes of memory for both 32 and 64-bit architectures in Java. Portable Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't require any implementation. High-performance Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native code. It is still a little bit slower than a compiled language (e.g., C++). Java is an interpreted language that is why it is slower than compiled languages, e.g., C, C++, etc. Distributed Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating distributed applications. This feature of Java makes us able to access files by calling the methods from any machine on the internet. Multi-threaded A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications, etc. Dynamic Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++. Java supports dynamic compilation and automatic memory management (garbage collection). C++ vs Java Comparison C++ Java Index Platform- C++ is Java is independe platform- platform- nt dependent. independent. Mainly C++ is Java is used for mainly used mainly used for system for programming application. programmin g. It is widely used in window, web-based, enterprise and mobile applications. Goto C++ Java doesn't supports support the the gotostate goto ment. statement. Multiple C++ Java doesn't inheritanc supports support e multiple multiple inheritance. inheritance through class. It can be achieved by interface s in java. Operator C++ Java doesn't Overloadi supports ope support ng rator operator overloading. overloading. Pointers C++ Java supports poin supports ters. You can pointer write pointer internally. program in However, C++. you can't write the pointer program in java. It means java has restricted pointer support in java. Compiler C++ uses Java uses and compiler compiler Interprete only. C++ is and r compiled and interpreter run using the both. Java compiler source code which is converted converts into source code bytecode at into machine compilation code so, time. The C++ is interpreter platform executes dependent. this bytecode at runtime and produces output. Java is interpreted that is why it is platform independent. Call by C++ Java Value and supports supports call Call by both call by by value reference value and only. There call by is no call by reference. reference in java. Structure C++ Java doesn't and Union supports support structures structures and unions. and unions. Thread C++ doesn't Java has Support have built-in built- support for in thread su threads. pport. Document C++ doesn't Java ation support supports comment documentati documentati on comment. on comment () to create documentati on for java source code. Virtual C++ Java has no Keyword supports virtual virtual keyword. keyword so We can that we can override all decide non-static whether or methods by not override default. In a function. other words, non-static methods are virtual by default. Hardware C++ is Java is not nearer to so hardware. interactive with hardware. Note o Java doesn't support default arguments like C++. o Java does not support header files like C++. Java uses the import keyword to include different classes and methods.

Use Quizgecko on...
Browser
Browser