Publicidad
Publicidad

Más contenido relacionado

Publicidad

1 Introduction to JAVA.pptx

  1. Introduction to JAVA P.Kanagaraju Technical Trainer Innate Talent 1
  2. Introduction to OOPs ■ Object-Oriented Programming System is the programming technique to write programs based on the real world objects. ■ OOPs Concepts
  3. Introduction to OOPs ■ Object – The Object is the real-time entity having some state and behavior.
  4. Introduction to OOPs ■ Class – A class is a group of objects which have common properties. – It is a template or blueprint from which objects are created. – A real-world example is Circle.
  5. Introduction to OOPs ■ Abstraction – Abstraction means hiding lower-level details and exposing only the essential and relevant details to the users. – Example: Consider an ATM Machine; ■ All are performing operations on the ATM machine like cash withdrawal, money transfer, retrieve mini-statement…etc. but we can't know the internal details about ATM.
  6. Introduction to OOPs ■ Encapsulation – Encapsulation is a process of wrapping data and methods in a single unit is called encapsulation. – In OOP, data and methods operating on that data are combined together to form a single unit, which is referred to as a Class. – Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safes from outside interference and misuse. – Real-world examples ■ The capsule, it is wrapped with different medicines. In a capsule, all medicine is encapsulated inside capsule
  7. Introduction to OOPs ■ Inheritance – Inheritance is a process of obtaining the data members and methods from one class to another class, plus can have its own is known as inheritance. – Inheritance - IS-A relationship between a superclass and its subclasses. – Super Class: The class whose features are inherited is known as a superclass (or a base class or a parent class). – Sub Class: The class that inherits the other class is known as a subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods.
  8. Introduction to OOPs ■ Polymorphism – The process of representing one form in multiple forms is known as Polymorphism. – Polymorphism allows us to perform a single action in different ways. – Polymorphism allows you to define one interface and have multiple implementations – Polymorphism means many forms. – Example
  9. Introduction to OOPs ■ Polymorphism 1. Object - Instance of Class 2. Class - Blue print of Object 3. Encapsulation - Protecting our Data 4. Polymorphism - Different behaviors at different instances 5. Abstraction - Hiding our irrelevant Data 6. Inheritence - One property of object is acquiring to another property of object
  10. Procedural languages vs OOPs Procedural Oriented Programming Object-Oriented Programming In procedural programming, the program is divided into small parts called functions. In object-oriented programming, the program is divided into small parts called objects. Procedural programming follows a top-down approach. Object-oriented programming follows a bottom-up approach. There is no access specifier in procedural programming. Object-oriented programming has access specifiers like private, public, protected, etc. Adding new data and functions is not easy. Adding new data and function is easy. Procedural programming does not have any proper way of hiding data so it is less secure. Object-oriented programming provides data hiding so it is more secure. In procedural programming, there is no concept of data hiding and inheritance. In object-oriented programming, the concept of data hiding and inheritance is used. Procedural programming is used for designing medium-sized programs. Object-oriented programming is used for designing large and complex programs. Examples: C, FORTRAN, Pascal, Basic, etc. Examples: C++, Java, Python, C#, etc.
  11. Applications of OOPs ■ Computer graphics applications ■ Object-oriented database ■ User-interface design such as windows ■ Real-time systems ■ Simulation and modeling ■ Client-Server System ■ Artificial Intelligence System ■ CAD/CAM Software ■ Office automation system, etc..
  12. History of Java ■ James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team. ■ Originally designed for small, embedded systems in electronic appliances like set-top boxes. ■ Firstly, it was called "Greentalk" by James Gosling and file extension was .gt. ■ After that, it was called Oak and was developed as a part of the Green project.
  13. History of Java Why Oak name for java language? ■ Why Oak? Oak is a symbol of strength and choosen as a national tree of many countries like U.S.A., France, Germany, Romania etc. ■ In 1995, Oak was renamed as "Java" because it was already a trade ■ Why they chosen java name for java language? The team gathered to choose a new name. The suggested words were "dynamic", "revolutionary", "Silk", "jolt", "DNA" etc. They wanted something that reflected the essence of the technology: revolutionary, dynamic, lively, cool, unique, and easy to spell and fun to say. ■ According to James Gosling "Java was one of the top choices along with Silk". Since java was so unique, most of the team members preferred java. ■ Java is an island of Indonesia where first coffee was produced (called java coffee).
  14. History of Java ■ Notice that Java is just a name not an acronym. ■ Originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995. ■ JDK 1.0 released in(January 23, 1996).
  15. Java Version History Version Release date JDK Beta 1995 JDK 1.0 January 1996 JDK 1.1 February 1997 J2SE 1.2 December 1998 J2SE 1.3 May 2000 J2SE 1.4 February 2002 J2SE 5.0 September 2004 Java SE 6 December 2006 Java SE 7 July 2011 Java SE 8 (LTS) March 2014 Java SE 9 September 2017 Java SE 10 March 2018 Java SE 11 (LTS) September 2018 Java SE 12 March 2019 Java SE 13 September 2019 Java SE 14 March 2020 Java SE 15 September 2020 Java SE 16 March 2021 Java SE 17 (LTS) September 2021 Java SE 18 March 2022 Java SE 19 September 2022 Java SE 20 March 2023 Java SE 21 (LTS) September 2023
  16. Features of Java ■ Simple – Syntax is based on C++ (so easier for programmers to learn it after C++). – Removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading etc. – No need to remove unreferenced objects because there is Automatic Garbage Collection in java. ■ Object-oriented – Object-oriented programming(OOPs) is a methodology that simplify software development and maintenance by providing some rules. – Basic concepts of OOPs are: ■ Object ■ Class ■ Inheritance ■ Polymorphism ■ Abstraction ■ Encapsulation
  17. Features of Java ■ Platform Independent – 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 software-based platform. The Java platform differs from most other platforms in the sense that it's a software-based platform that runs on top of other hardware-based platforms. It has two components: ■ Runtime Environment ■ API(Application Programming Interface) – java is platform independent Java code can be run on multiple platforms e.g. 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).
  18. Features of Java
  19. Features of Java ■ Secured – No explicit pointer – Programs run inside virtual machine sandbox.
  20. Features of Java ■ Secured – Classloader- adds security by separating the package for the classes of the local file system from those that are imported from network sources – Bytecode Verifier- checks the code fragments for illegal code that can violate access right to objects – Security Manager- determines what resources a class can access such as reading and writing to the local disk
  21. Features of Java ■ Robust – Robust simply means strong – Java uses strong memory management – There is automatic garbage collection in java – There is exception handling and type checking mechanism in java. All these points makes java robust. ■ Architecture-neutral – There is no implementation dependent features e.g. size of primitive types is set. ■ Portable – We may carry the java bytecode to any platform. ■ Distributed – We can create distributed applications in java – RMI and EJB are used for creating distributed applications – We may access files by calling the methods from any machine on the internet.
  22. Features of Java ■ High-performance – This language uses Bytecode which is more faster than ordinary pointer code so Performance of this language is high. – Garbage collector, collect the unused memory space and improve the performance of application. – Java is an interpreted language, so it will never be as fast as a compiled language like C or C++. But, Java enables high performance with the use of just-in-time compiler ■ 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 shares the same memory. Threads are important for multi-media, Web applications etc.
  23. Where it is used? ■ More than 3 billion devices run java. There are many devices where java is currently used. Some of them are as follows: ■ Desktop Applications such as acrobat reader, media player, antivirus etc. ■ Web Applications such as irctc.co.in, javatpoint.com etc. ■ Enterprise Applications such as banking applications. ■ Mobile ■ Embedded System ■ Smart Card ■ Robotics ■ Games etc.
  24. Types of Java Applications ■ 1) Standalone Application – It is also known as desktop application or window-based application – An application that we need to install on every machine such as media player, antivirus etc. – AWT and Swing are used in java for creating standalone applications. ■ 2) Web Application – An application that runs on the server side and creates dynamic page, is called web application – Currently, servlet, jsp, struts, jsf etc. technologies are used for creating web applications in java.
  25. Types of Java Applications ■ 3) Enterprise Application – An application that is distributed in nature, such as banking applications etc. – It has the advantage of high level security, load balancing and clustering. In java, EJB is used for creating enterprise applications. ■ 4) Mobile Application – An application that is created for mobile devices – Currently Android and Java ME are used for creating mobile applications.
  26. Advantages of Java ■ Java is open source ■ Java is fast and high-performance ■ Java is easy to learn ■ Java is statically typed – Unlike languages like Python or JavaScript, Java is statically typed. – In Java, you specify whether a variable is a float, double, int, Integer, char or String. ■ Java feature addition is fast ■ Java is object-oriented ■ Java supports functional programming – Functional programming (FP) is an approach to software development that uses pure functions to create maintainable software
  27. Keywords in Java
  28. Path Setting ■ Windows 10 – In Search, search for and then select: System (Control Panel) – Click the Advanced system settings link. – Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. – In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. – Reopen Command prompt window, and run your java code. https://java2blog.com/how-to-set-java-path-windows-10/
  29. Simple Program Execution ■ Step 1: Write a program on the notepad and save it with .java (for example, DemoFile.java) extension. class DemoFile { public static void main(String args[]) { System.out.println("Hello Java"); } } ■ Step 2: Open Command Prompt. ■ Step 3:Set the directory in which the .java file is saved. ■ Step 4:Use the following command to compile the Java program. javac DemoFile.java ■ Step 5:Use the following command to run the Java program: java DemoFile
  30. Simple Program Execution
  31. Java Lexical Issues or Java Lexeme or Java Tokens ■ Java Tokens are the smallest unit of a Java program ■ Various Java tokens are whitespace, identifiers, literals, comments, operators, separators, and keywords. ■ Whitespace – White space can contain the characters for tabs, blanks, newlines, and form feeds. – These characters are ignored except when they serve to separate other tokens. However, blanks and tabs are significant in strings. ■ Identifiers – Identifiers are used to name things, such as classes, variables, and methods. – uppercase and lowercase letters, numbers, or the underscore and dollar-sign characters – They must not begin with a number – Java is case-sensitive
  32. Architecture of Java Lexical Issues ■ Literals – A constant value in Java is created by using a literal representation of it. For example, here are some literals:
  33. Architecture of Java Lexical Issues ■ Separators
  34. Primitive data types in Java
  35. Typecasting in Java ■ In Java, type casting is a method or process that converts a data type into another data type ■ Types – Widening Type Casting – Narrowing Type Casting
  36. Typecasting in Java ■ Widening Type Casting – Converting a lower data type into a higher one is called widening type casting. It is also known as implicit conversion or casting down. It is done automatically. ■ byte -> short -> char -> int -> long -> float -> double public class Main { public static void main(String[] args) { int a=78; double d=a; System.out.println(d); } } Output: 78.0
  37. Typecasting in Java ■ Narrowing Type Casting – Converting a higher data type into a lower one is called narrowing type casting. It is also known as explicit conversion or casting up. It is done manually by the programmer. ■ double -> float -> long -> int -> char -> short -> byte public class Main { public static void main(String[] args) { double d=23.67; int a=(int)d; System.out.println(a); } } Output: 23
  38. Architecture of Java
  39. Architecture of Java ■ Narrowing Type Casting – Converting a higher data type into a lower one is called narrowing type casting. It is also known as explicit conversion or casting up. It is done manually by the programmer. ■ double -> float -> long -> int -> char -> short -> byte public class Main { public static void main(String[] args) { double d=23.67; int a=(int)d; System.out.println(a); } } Output: 23
  40. JVM, JDK, JRE ■ 1. JVM stands for Java Virtual machine, JDK stands for Java development kit, and JRE stands for Java runtime environment. ■ 2. JDK is for the development environment whereas JRE is for the run time environment. ■ 3. JVM runs inside the JRE environment. JRE contains class libraries, Java Virtual Machine and other files other than development tools like compiler and debugger. ■ 4. JRE is a subset of JDK. JDK contains JRE along with development tools such as compiler, debugger, etc.
Publicidad