PRESENTATION ON JAVA. WRITE ONCE RUN ANYWHERE. WHAT IS JAVA? Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java has many characteristics that have contributed to its popularity: 1. Platform independence - Many languages are compatible with only one platform. Java was specifically designed so that it would run on any computer, regardless if it was running Windows, Linux, Mac, Unix or any of the other operating systems. 2. 3. Simple and easy to use - Java’s creators tried to design it so code could be written efficiently and easily. 4. Java does have some drawbacks. Since it has automated garbage collection, it can tend to use more memory than other similar languages. There are often implementation differences on different platforms, which have led to Java being described as a “write once, test everywhere" system. Multi-functional - Java can produce many applications from command-line programs to applets to Swing windows (basically, sophisticated graphical user interfaces). 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. OOPs (Object-Oriented Programming System) Object means a real-world entity such as a pen, chair, table, computer, watch, etc. ObjectOriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts: ● Object ● Class ● Inheritance ● Polymorphism ● Abstraction ● Encapsulation Features of OOPs The Objects Oriented programming language supports all the features of normal programming languages. In addition it supports some important concepts and terminology which has made it popular among programming methodology. The important features of Object Oriented programming are: ● ● ● ● Inheritance Polymorphism Encapsulation Method Overloading Inheritance Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another. ... The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class). Polymorphism The word polymorphism comes from the word poly(many) morphos (form). It is the process in which the same entity behaves differently in different situations. e.g: 9+5=14 hello+world= helloworld Here ‘+’ operator behaves differently in different situations. Polymorphism is 2 types 1.Static polymorphism:- When the polymorphism is achieved during compile time then it is known as static polymorphism.E.g:method overloading / function over 2.Dynamic polymorphism :- When the polymorphism is achieved during runtime or executing time then it is known as dynamic polymorphism. E.g :-method overriding / function overriding. Encapsulation Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Overloading Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. It is similar to constructor overloading in Java, that allows a class to have more than one constructor having different argument lists. Reusability Reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class. DATA TYPES IN JAVA Primitive types are the most basic data types available within the Java language. There are 8: boolean , byte , char , short , int , long , float and double . These types serve as the building blocks of data manipulation in Java. Such types serve only one purpose containing pure, simple values of a kind. Conditional Statement in Java The Java if statement is used to test the condition. It checks Boolean condition: true or false. There are various types of if statement in Java. ● if statement ● if-else statement ● if-else-if ladder ● nested if statement Looping Statements In programming languages, loops are used to execute a set of instructions/functions repeatedly when some conditions become true. There are three types of loops in Java. ● for loop ● while loop ● do-while loop Method Overloading and Overriding (1)Overriding implements Runtime Polymorphism whereas Overloading implements Compile time polymorphism. (2)The method Overriding occurs between superclass and subclass. Overloading occurs between the methods in the same class. (3)Overriding methods have the same signature i.e. same name and method arguments. (4)Overloaded method names are the same but the parameters are different. (5)With Overloading, the method to call is determined at the compile-time. With overriding, the method call is determined at the runtime based on the object type. If overriding breaks, it can cause serious issues in our program because the effect will be visible at runtime. Whereas if overloading breaks, the compile-time error will come and it’s easy to fix. Abstraction We can perform abstraction by abstract class or interface. Abstraction is the process of representing essential features without including the unnecessary details (background details). Abstract Class An abstract class is a class that is declared abstract it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. Interface An interface in Java is a blueprint of a class. It has static constants and abstract methods.The interface in Java is a mechanism to achieve abstraction. There can be only abstract methods in the Java interface, not method body. It is used to achieve abstraction and multiple inheritance in Java. In other words, you can say that interfaces can have abstract methods and variables. It cannot have a method body. Difference between Abstract class and Interface Java Packages A package in Java is used to group related classes. Think of it as a folder in a file directory. We use packages to avoid name conflicts, and to write a better maintainable code. Packages are divided into two categories: (1)Built-in Packages (packages from the Java API) (2)User-defined Packages (create your own packages) THANK YOU!!!