 Hello everyone, this is Ajay and I am going to tell you about the Java for Android part 2. So, in the first session you will learn various different object-oriented principles as well as you see in a different data types you also learn how to develop a simple Java program. Now, in the in this session I am going to cover the first that is classes and object. So, the first one is the classes and object in that I am going to tell you how to create the object, second one how to call the method and a constructor which is a special method for implicit way of object creation. Then the overloading in that I will tell you how to overload the methods as well as the constructor. Then we have inheritance, access modifiers in that we have a different access modifiers and the overriding and at the end managing and managing the errors and exception. Now, what is the classes? Classes and objects. So, the class is a collection of fields that is data and methods that operate on that data. So, class contains the fields that is the member variable and the properties that is the method. By defining the class in Java we can create a new data type and we can declare the variables of that data type. That means the class is a user defined data types like we have in like we have a built in data types such as end, float, character. We can define our own custom data types and by using that we can create the object as well as we can create the as well as we can invoke the methods or properties using that object. So, this is the general definition of the class. So, this is the class name and whatever be in the square bracket is optional. That means I can have a empty class which is valid Java class and I can even create the object using that class. This is a class which having a name rectangle. Then in the red color we have two variables length and width which is a member variable and member variable 2. Then we have a two methods which is in blue set data and rect area. So, set data method initializing the length and width parameter of the rectangle class and the rect area is giving me the area by the multiplication of the length and width. So, how to create the object of this class? So, here I have a syntax rectangle r equal to new rectangle. So, using this statement I can create the object of this rectangle and here in this diagram I can access the variables as well as the methods using the object r. Now, I will show you the program. So, this is the rectangle class that I have shown two slides and this one is the another file in which I have a main method for calling for creating the object of that class. So, here I have area 1 and area 2 two variables two integer variables where I will store the area. Then in this I have created two objects of rectangle class. Then I am initializing the length and width parameter to 15 and 10 then I am storing the multiplication of length and width into the area 1 and then I am printing it. But in this I have not used any methods such as set data or rect area. So, for creating the area 2 I will use the method set data by passing the two parameters 30 and 10. So, which will go directly over to this method and it will initialize the length and width parameter and then I am calling the rect area using the rect 2 object and the pointer will go over there and it will calculate the area and it is returning the area and that I am storing it in a area 2 integer variable and then I am printing. So, now I will run this and now you can see I have calculated the area 1 without using the methods and area 2 with using the methods. Next, so next we have methods and constructor. So, in the previous session you learn what is the method, but what is the constructor? So, constructor is used to initialize the member variable of the class at the time of object creation. So, instead of having a method such as a set data for initialization of the length and width parameter we can have a constructor which will initialize the both the member variables such as length and width at the time of object creation. So, here I have a rectangle class constructor, so in that you can see the difference between the methods and constructor that is in the rectangle I do not have any return type as well as I do not have any access modifier and in this table I am comparing the method and constructor. So, that you will get the better idea of what is a constructor. So, the return type, so method must have a return type, constructor for the constructor we do not need return type. So, the return statement inside the body, so method can have a return statement depending on the access modifier depending on the return type, but the constructor does not need return type since it does not have a return type name. So, method can have any valid name, but the constructor in the constructor the constructor name should be same as of its class. And the last point method is not used to create the object of its class, but the constructor help us to create the object of its class. I will show you the demo of constructor. So, in that I have this method set data and I will convert this method into the constructor. So, I will give the name rectangle same as of class. So, now this is the constructor and I will call this constructor into the main method. So, now here I am getting the error because the constructor taking the two parameter two integer parameters. So, I will comment this out and I will pass the two parameters 2020. And here now I do not need to call the set data method on Rake 2 and I can get the area 2. Now, I will run this example and now you can see I got the area 20 into 20 as 400. So, overloading, so as you can see in the figure area. So, I can calculate the area depending on the different objects. So, this is the rectangle I can get the different area than the triangle. So, what is the definition? Two or more methods within the same class. So, assume that this is in the same class and share the same name. So, here I am sharing the same name gate area here also I am sharing the same name gate area, but their parameter declaration or return types are different. So, parameter declaration I have here only two parameters, but for a triangle I have a three parameters base height and value or return types are different. So, here I have a return type int and here I have a double. So, that means this concept is called overloading. So, what is that? Two or more methods within the same class, two or more methods within the same class and share the same name, but their parameter declaration or return types are different. So, it is like a one thing and many form. So, now I will show you the demo for it the program. So, this is the rectangle class where, so this is the rectangle class and here I have a method set data and I am overloading this and I am overloading this set data method for one integer parameter. So, here I have overload set data for one integer parameter and again I am overloading the same method for two integer parameter and at the end I have a rect area method which will give me the area by the multiplication of length and width. So, in the main method I have created the three objects rect 1, rect 2 and rect 3 and then I am calling each and every method using the different object. So, set data method by rect 1, set data with one parameter by rect 2 and set data with two integer parameter with rect 3 and I am calculating the area. Now, I will run this application and now you can see I got the three areas 100, 400 and 150 debating on the values. Now, what is the inheritance? So, inheritance is the process by which the object of one class acquires some or all the properties of another class. So, what is the subclass? So, in this diagram I have a vehicle which is a very super and general class and which has some common features and I can draw the two subclasses out of this super class which is a very special class that is car and truck are very special than the vehicle. So, what is the difference between car and truck? Car may have four wheels or truck may have more than four wheels and I can again draw the sports car subclass out of the car class. So, sports car may have a stronger engine than car. So, it is like the parent child relationship. So, now I will show you the demo for the inheritance. So, this is the super class a simple example of inheritance. So, where I have two variables and I am just printing that i and j using the show ij method and what is in the subclass? So, class sub extends super. So, this keyword is used for extending the superclass or for creating this or for taking the properties from the superclass. And here in the subclass I have a variable k and I also have a show k method which printing which prints the k value and at the end I have a some variable which print which prints the all the variable sum. So, here you can see I can access the i and j though I do not have the i and j variable in the subclass. That means, I am inheriting the i and j variable in the subclass. So, here accessing the i and j variable of superclass at the simple in the main method I have created the super object, I have created the sub object and here I am initializing the i and j with 10 and 20 by using the super object and I am just calling the show ij for printing the content then I am using the sub object for initializing the all the 3 variables that means, I can initialize the i and j as well using the sub object. So, that means, inheritance and rest of the things I am in the in the end I am printing the i and j variable as well as the k variable using the show k method and the sum. Now, I will run this application. So, here I am getting the content contents of super object that is 10 and 20 contents of sub that is i and j is 7 and 8 and k is 9 and sum of the all is 24. So, I am continue with the next slide that is. So, in the previous session what we have seen the classes and objects overloading and the inheritance concepts. Now, I am starting with the access modifiers. Now, what is the access modifier? So, it is like a can I access the variable using the methods in subclass or can I access the method in the subclass of another package. So, it is like that. So, here I have a table. So, these are the different access modifiers in Java. So, first one is public, second one is private, default and private. So, public. So, public is like I can access the variable in the entire world that is in the entire project. So, therefore, public field I can access in the same class as well as I can access in the subclass in the same package as well as in the other classes, subclasses in another package and non subclass in another package. But what about the protected? I can access into the all field except non subclass in the other package. But what about the default? I can access in the same package that is in the same class, subclass in the same package, other class in the same package, but I cannot access in the subclass in another package as well as the non subclass in another package. And what is the private? I can access only within the same class. So, in this diagram I have a package P1 and package P2. So, in the package P1 I have a class C1 which is a superclass and it has four different variables having a different access modifier. So, if there is no access modifier that means it is a default access modifier that is int A. Then I have a public int B, private int C and protected int E and each has a different color. Now in the package P1 I have two more classes. One is the class C2 which is a subclass of the upper class that is a class C1 and I have a non subclass C3. So, here you can see I can access the variable A of a superclass because it is a default modifier, default variable. I can access B and I can access D, but I cannot access the C in this class C2. But what about the class C3? So, it is a non subclass, but it resides in the same package as a superclass. So, here I can access the default variable that is int A and I can access the B, but I cannot access the C because it is a private and I also cannot access the protected int D because it is not the subclass of the superclass. Now we will go to the package P2. So, this is the package P2 and here I have a two class class C4 and class C5. So, class C4 is the subclass of the class C1 in the package P1. So, I can access the variable B because it is a public and which is visible to all the packages. So, I can access the B as well as I can access the D because it is a subclass of the superclass, but I cannot access the A and C. So, default access variable we can access in a same package, but not in the different package. And what about the class C5 which is a non subclass and I can access only B and I cannot access the rest of the three that is A, C and D. Now, I will show you the demo for this. So, I have a class test and where I have default access variable that is int A, then I have public int B and private int C. Then I have one method that is void set C since the C is a private variable. So, for accessing the private variable I need to use this two method that is set C for setting the value that is for initializing the variable C and for getting the value I am using the get C. Now, in the main method I can access the A and B and I can assign the value to 10 and 20, but I cannot access this, this is not okay and will cause a error that is I cannot access the C because it is a private. So, for that what is the solution? You must access C through its method. So, that is why I use the set C method which will assign the 100 to the C and then I am printing all the variables. I can directly print the A and B, but if I want to print the C I need to use the get C method. Now, we will run this and here we got the output that is A, B and C 10, 20, 100. Now, we will go to the next slide. Now, what is the overriding? So, overriding is what the method in the superclass is overridden in the subclass that is the method in the child class will have the same signature as that of the superclass. So, in the overriding I need to have the same signature that is I have I need to have the same access modifier as well as the same written type that is the total signature all the signature should be the same. So, here you can see I have a two class that the first is super and the second one is the subclass extending the superclass and here I have void print stuff. So, the signature of this method is same as the signature in the subclass, but what about the statement inside the method? So, here I am printing the A, but here I am printing the B. So, it is called the overriding. Now, I will show you the demo for it. So, this is the superclass here I have a two variable ij and this is the constructor which is which initializes the i and j variable and then I have a show method which prints the i and j. Then I have a subclass which is extending the superclass, then I have a k and here I have a constructor sub constructor of the subclass and there I have a three variables in A, B and C and I am using the super keyword for calling the superclass constructor. So, the super keyword is used to call the superclass constructor and then I am initializing the k variable and here I have a show method and I am printing the k case value in the show method and if I want to call the show method of the superclass I can use the super dot show. So, that it will call the superclass show method show method. Now, what is in the main? So, here I have created a sub object and I have initialized the 1, 2, 3 to the i, j and k and then I am calling the show method. Now, we will run this and here I got the output k in sub k in subclass that is 3 and i and j in the superclass 1 and 2. Now, the over loading and over adding is a very confusing concepts. So, for that I will compare both the concept. So, what about the method signature? So, in the over loading it should not be the same that is I can have a different axis modifier, but for the other method I can again I have a different axis modifier, but what about the over adding? It should be the same then axis modifier can have any axis modifier, but what about the over adding? I must have same or wide axis modifier than the superclass method axis level. Then what about the return type? Method can have any return type, but in the over adding concept method return type must be the same as the superclass method and over adding occur in the same class that it happens in the same class over loading, but what about the over adding? It occur between the superclass and the subclass. Now, whenever we write the code sometimes we forgot to put the semicolon or sometimes we make the errors. So, what are the different types of errors we have in Java? So, here I have a two types of error compile time error and runtime error. So, what is the compile time error? In the compile time error all the syntax errors will be detected and displayed by the Java compiler at compile time. So, if I forgot to put the semicolon at in any statement it will give me the error that means it is a syntax error and the program will not compile successfully, but what is the runtime error? In the runtime error the program will be compile successfully that means there will be no syntax, syntactical error, but may not run properly due to the wrong logic such as division by 0. So, here at the runtime time at the runtime error it will give me the error due to the wrong logic such as a division by 0. So, I will show you the demo for it. So, here I have a class error in the main method I have a three variables a equal to 10 b equal to 5 and c equal to 5 and then I have a one more variable x which will give me the output of this expression. So, a divided by b minus c. So, first the b minus c will execute and then it will divided by a it will divide to a. So, then I am printing the x variable. So, suppose I forgot to put the semicolon then what it gives me the error that syntax error insert the semicolon to complete the statement. So, this is the compile time error now I will show you the runtime error. So, for that I need to run and here you can see the java dot lang dot arithmetic exception error at java 9. So, this means it is a runtime error and for solving these types of error I need to make the correct logic or if I want to catch this error I have a concept called exception handling. Now, what is the exception? So, exception is the condition that is caused by the runtime error in the program or due to the wrong logic and how to handle that exception? It provides a means to detect and report an exceptional circumstances. So, that the appropriate action can be taken. So, what are the steps to handle the exception? So, first one is find the problem then indicate that error has occurred then receive the error information and take the corrective action. So, what is the syntax for handling the exception? So, syntax for handling the exception. So, here I have a try, try block and catch block. So, whatever be the error in the try block it will generate the exception and it will pass that exception that means the catch block will catch that exception and the statement is statement will take the corrective step to handle that exception. Now, I will show you the demo for it the program of exception handling. So, for that I need to write the try block and now I can handle the exception this is exception. So, here now I included these two statement into the try block and it will fire the error and the catch block will catch that exception. Now, I will run this program and now I would not get any error. So, you can see first it prints this is the exception and then I then it will execute the further statements that is here I am calculating the value of y b plus c which will 10 and a by a by 10 10 by 10 which is 1. So, at the end summary what we have seen definition of class how to create the object what are the definition what is the definition of method and constructor what are the different access modifiers what is the inheritance that is super class and sub class it is a parent and child relationship and we also seen the overload and overriding of methods and at the end we seen exception handling. Now, Pradhan will tell you the introduction of Android. Thank you.