 I am Assistant Professor from Department of Electronics from Valgen Institute of Technology, Sallapur. Today, I am here to have a session on Introduction to Oops and Principles of Java. After the end of this session, student will be able to have introduction to Java, concepts of Oops, difference between Procedural and Oops and Principles of Java. Let us start with Introduction to Java. Java is a simple programming language easy to read and learn. Anybody can start with Java with the understanding of basic underlined principles of Java. Where is Java used? Java has been the choice of freshers as well as the experienced programmers. Java is widely used in web applications, is used in creating Android applications and game development. What is procedural programming? Procedural programming can be defined as programming model which is derived from structured programming based upon the concept of calling procedures. Procedures are also called as routines, sub-routines or the functions. Simply consist of series of computational steps to be carried out. So C programming is a procedural language, so each and every statement in C program is executed step by step in a particular sequence. So C programming is a series of computational programming steps to be carried out. What is object-oriented programming? Procedural programming is about writing procedures or the methods that perform operations on the data, while object-oriented programming is about creating objects that contains both data and methods. Why object-oriented programming? So far we have built two kinds of CPP programs. First is the procedural and the functional. The program moves through a linear series of instructions in procedural language. So in C program, each and every statement is executed in a sequence which is the series of instructions and it also consists of functions where you have the main function. In that if you have the function, the program cursor will call the function, it will go to the function definition, execute the statements in the function definition and come back to the main program and execute the main code. This is the functional that the program moves from one function to the another function. Let us consider the physical object, a light bulb. You are only bothered to turn on and off the light bulb. You are least bothered about the functionality or the internal functioning of the light bulb. Similarly, object-oriented programming is a programming allowing you to package together data states and the functionalities which will hide the details which are not required, keeping the details hidden away like the light bulb. As a result, all the design is flexible, modular and abstract. This makes it particularly useful when you create larger programs. Let us have a comparison between procedural and the object-oriented programming. In procedural programming, program is divided into smaller parts called functions whereas in object-oriented programming, programming is divided into smaller parts called objects. Object-oriented programming follows the top-down approach whereas the object-oriented programming follows the bottom-up approach. There is no access specifier in procedural language whereas the object-oriented programming has access specifiers like public, private and protected. Adding new data and function is not easy in procedural-oriented language whereas adding new data and functionality is easy in object-oriented programming. Procedural programming does not have any proper way for hiding data so it is less secure whereas object-oriented programming provides data hiding so it is more secure. In procedural programming language, function is more important in data whereas in object-oriented programming, data is more important than function. Let us start with the principles of object-oriented programming. So the principles of object-oriented programming are object, class, inheritance, polymorphism, abstraction and encapsulation. Let us see the principles of object-oriented programming one by one. A class is a template for objects and an object is an instant of class. When the individual objects are created, they inherit all the variables and methods from the class. So let us take one example. Fruit is an in-general classification of class and object consists of apple, banana and mango. So apple, banana and mango are the classification of fruit. So fruit is what? It is a template of class whereas the apple, banana and mango are classification of the fruits. So objects inherit all the variables and methods from the class whereas the class is a template for object. Class is a template or blueprint from which objects are created. Let us have one more example of car which is a class and there are objects like Volvo, Audi and Toyota. So Volvo, Audi and Toyota are the classification of the cars but car is an in-general classification. So car is referred to a class and Volvo, Audi and Toyota are referred as an objects. An object is an entity that has state and behaviors. For example dog, cat etc. To illustrate a dog has states like age, color, name and behavior like eating, sleeping and running. So state tell you the appearance of the dog like what is the age, what is the color, what is the name whereas the behavior tells you about the eating, sleeping and running that what the dog does. So state tells us how the object looks or what the properties it has whereas the behavior tells what the object does. Let us start with next principle that is inheritance. Inheritance is a mechanism in which one class acquires the properties of the other class. For example a child inherits the traits of his or her parents. So this example gives you the perfect idea for the inheritance. So parents inherits all his properties to the child. So this is how the inheritance between the parents and the child is shown. Similarly there is a parent class and the child class. So child class will inherit all the properties from the parent class. So this is how the inheritance mechanism works. In Java there are various types of inheritance, single, multiple, multilevel, hierarchical and hybrid. For example, so assume we have a class animal and a subclass of name is dog. Our dog acquires the properties of the animal class. Other classifications could be donkey, monkey, lion, etc. The extend keyword is used to perform inheritance in Java. So there is an animal class and there is a class dog. Dog is going to have the inheritance from the parent class called animals. So extend keyword is used to show the inheritance between the classes dog and the animal. Next is abstraction. Abstraction is process of hiding the implementation details and only showing the functionality to the users. So if you want to send an SMS, you just type the SMS and the number. You are not bothered about the internal process of message delivery. The same thing abstraction lets you know what the object does instead of how it does. Encapsulation is mapping of code and data together in a single unit. So like a capsule, it consists of several medicines encapsulated in a single unit which keeps it protected. So this can be achieved by the private access modifiers that cannot be accessed by any other outside the classes. So encapsulation nothing but wraps the code and the data together in a single unit and you have the access specifiers like private and protected. Next is the polymorphism. Polymorphism means many forms. It occurs when we have many classes that are related to each other by inheritance. We have seen the inheritance so polymorphism uses those methods to perform different tasks. This allows us to perform single action in different ways. For example you have a superclass animal and you have the subclasses like pig, cat, dog and birds and you want to write a program to capture the sounds of the animals. So animal is the superclass, subclasses are pig, dog. So pig will extend from the animal class. So this is the inheritance shown by the keyword extend. So class pig is going to have inheritance from the animal class, class dog, another subclass which is showing the inheritance with the animal class by this word keyword extends. The references are taken from Java a beginners guide, core java 2, volume 1 fundamentals and java 2 the complete reference guide.