 Good morning. Let me see the presentation. Today we are going to see the presentation of java, jsp and javascript. This I am Rajavell. This I am past 4 years I am working in clicker application. Let me start with java. How many of them familiar with java? More than 1 of I think 75 percentage. Jsp 25 percentage. Javascript 50. Okay fine. Okay. This most of them knows java is an object oriented then platform independent. What is object oriented? C++. I think you may study C++ correct. How many of them knowing about C++? C++ almost. Okay. C++ also a object oriented and java also object oriented. Is there is any difference between this both or both are different? Pointers. Java do not have pointers. Then anything else? The platform java gives the feature of platform independent and anything else? Is it C++ purely object oriented? Why? Sorry. Yeah in C++ we can write C++ program without creating a class. So it mean that without creating an instant there is object we can use any methods or functionalities. So it violating the pure object oriented principles. So java it is a pure object oriented principles. Okay. And it is simple if you know the basic programming concepts and then secure. It has a built in security like public encryptions. We can use this encryptions all the security features to make your application more secure. And then multi-threading. It gives the feature of multi-threading. We can do multiple process for a single program. Then high performance. What is high performance? It is like gives the like just in time compilations. Okay. How the platform independent works? Like platform independent what is the platform independent? The code has to be run on all the platform like whether it may be the windows or Unix or Macs. Mac whatever it is. So how it works? If you write any java program when you compile it will convert into byte code. It is a main like feature is byte code. That is the strength of java byte code. The byte code for example if you are developing any java program in windows after you compile you will get the byte code. That byte code you can execute in any operating system. For example Unix you can execute the same code which is running on like windows. That is the byte code works. So who is running that byte code? JVM. Java virtual machine. It is the one executing your byte code. That is the class. Byte code is the class file. So this is how platform independent works. Okay. Let me start with some basic just terms we used to almost we use it in a java programming. First one is the object. What is the object? In real time you consider like do not go with java. Every a chair, pen, book, table, car everything is the object. Each object have its own state as well as behavior. For example if you take it as a camera. Camera has their own state. What are the states? Color of the camera and then the resolutions, the optical zoom. So these are some state behavior. What is the behavior of a camera? A click photo, take video, stop the recording. So these are some behavior. Okay. So likewise java also same. The object have a state as well as the behavior. That is the object. Okay. Next one is a class. What is the class? Class is a like integration of like attributes as well as the member variable as well as member functions. That is a class. Okay. It describes the state and behavior. Okay. And method is what we are just telling about the behavior. The behavior we can achieve through method or function. Okay. Next one is a instant variable. Instant variable defines the state. Okay. So what we like mention? The color, the size, everything it was is a state. We can make this achieve through instant variable. Okay. This is a basic term we are almost used in a java. Okay. Before getting into java programming, you have to keep some important points in your mind. Okay. The first one is a case sensitive. So many of them knows about the case sensitive. Like it has a, it gives the case sensitive like hello with h capital hello with h small letter is a different meaning. Okay. As well as second one class name. The class name, the most of the people when you are starting on a java programming, they are not following the standard of javas coding standard. So in java class name should be how it should be? The first character of each word should be capital. For my class m is a capital. C is a capital. So that is a naming format. And then method. How the method should be? Other than first character of first word, the same as class name. Okay. Then program file name. The program file name should be same as class name, public class name. Is it mandatory? How many of them telling it is mandatory? The class name and then program file name should be same. Okay. Just actually are using ID. Which ID you are using? Eclipse. So that is why you are not that much familiar with what is the difference? What ID, when you are using ID, simply we used to run, when you run button, it will give the results. But actually what is happening? The java code is compiling. The ordinary, if you are using terminal, what you used to do? You have to give java c. What is that? That is a file name. When you are creating a file name, when you are compiling, the name of the class is created a class file. For example, I having a one file myfile.java. But inside, I have one class, the class name is my class. The class name is my class, but file name is myfile.java. How to compile java c. Myfile.java. But after compilation, it gives the result as myclass.class. There is a class file it gives. So after, how to execute? Java, you have to give the class name, myclass. So we can give the different naming in file as well as class. But when we are using in ID, we are not much familiar with this case. But most of the IDs gives the warning, the name should be same as file name. Based on this compatibility, that IDE compatibility. So this is the some small tips. Then simple program, like java program start with execution now, execution start with public static void main method. It is having a argument that is a string arguments. String array arguments. In this program, the class name is hello world app. The execution start with main method. In main method I am creating object for the same class. The object name is hello. And in this class having one member function, the member function is say hello. Simply it will print the system dot outdoor print alarm. What you know anything about system dot outdoor print alarm? It is used for printing the statement. Then after just simple one method is there, simply print the one statement that is hello. In main, I am creating an object. Using that object, I have created the, just I am simply invoking the method, the member function say hello. So after execution of this, it will simply print hello that is all. What is the purpose of creating an object? Is it mandatory? Actually the thing is that I am in a same class, but the method say hello also in a same class. So is it mandatory to invoke through object? What is happening actually? When you are creating object, this you are creating on class, you have created an object. What is the internal structure? If you are doing this, the first line of main function, what is happening? When you write this statement. So actually what is happening internally? You are creating object, creating a class. The class has n number of variables as well as n number of methods. It has, it is the memory is not created for the class. Correct? Simply it is there. When you are creating an object using new keyword, it is creating a memory for a class to share, to access their members. So if I creating one object is hello. The hello has the memory space for accessing these members in a class, my, sorry, hello world app. Again I am creating another object. What is happening? It is sharing the same memory space which is created existing, already created, no. When creating another object, it is creating another memory space for the another object. So likewise how many objects you are creating for the class? Each one sharing their own memory space. Okay? You understood? Okay. Like I think I no need to execute this program in ID. Do you want? I will go with some, some other program. Sir. Yeah. When is the memory for the method hello created? After creating an object or after creating a class? Yeah, after at the create, no, no, at the time of creating a object. Yeah, the object is for accessing that particular method. Sorry, actually it is creating a frame of class, but the memory space, the separate memory space to access the particular method is created at the time of creating object. Understood, no? For example, for if I am simply having a method some, some having a two variable a plus b. So the functionality is going to be same for all the, all the objects. So that is created. But according to the memory space, what is different? Sure, the memory space for accessing that particular method is different. When I just, you can exactly feel the difference at the aim of static. Static access modify, you, you come to know the exact difference. You can feel it. What is the object space? What is the class? Like sharing their own member functions? This is the access modifiers. Okay? Before getting to access modify, I will let you know just two terms that is package and then subclass. Package is a simple folder. It have all related classes. That is a package. Okay? Then subclass, the class is derived from another class. That is a, what is that? Subclass. Just I tell you about subclass in detail in like abstracted principles. That is the inheritance. It is a reusing the property of existing classes. That is the inheritance. That is the subclass. Okay? For example, I am having one class, having a two method, some, sorry, addition, division, multiplication, three, three method I am having. The same functionality I am going to use it for some other class. So, is it no need to recreate the same methods again? Simply we can reuse it. So, that is a subclass. Okay? So, the class which is created newly, it is going to use the property of existing class. Okay? Access modifier. In Java, have four access modifiers. That is a public, private, protected, and the no modifier. The no modifier is a, you are not mentioning any modifiers like protected, public, private. If you are, leave the space, you are not mentioning anything. That is a no modifier. Okay? Public, it can be access inside a class, as well as inside a packages and then subclasses. And rest of the world, it means that from anywhere you can access it. The public access okay? Then protected, protected other than the rest of the world. Like they can use, they can access their own number. That is a class, inside class packages as well as subclasses. No modifier, only within a class as well as packages. Private, it is a only within a class. I will give you an example. Okay? Your name? Mohit. Where are you from? Kalyan. Okay, but where you study? Okay, fine. Then what is your father name? Laxman. Okay, good. What is your girlfriend name? You do not have a girlfriend. Okay? Okay. Okay. Let me discuss after. Oh, you want to, no, you want to disclose. That is a, what is that? Protected. It is not private. So, if his close friend asks, definitely he will disclose. Correct? Even if he won't disclose, disclose. Enclose friend also. It may be. Okay? If I am asking his girlfriend mobile number, will he disclose? Never. That is a private. So likewise, it works. Okay? Based on the access scope, we can access the each modifiers. Understood, no? Just I am asking about understanding about the access modifier. Okay? Okay, fine. Okay, let me see one example for access modifier. Okay? I am created one class. The class name is access modifier. This class having four variable. First one is a public. The name of the variable, PUB, private, that is a PIV. Another one is a protected, PROT. Then last one is a DEF, that is a no modify. Okay? I am accessing, I am creating one like member function. The member function name is display. Simply it will display the value of each variable if I assign any values. Okay? Let me discuss what is the meaning of this. Okay? We will leave now about this keyword. Okay? In main method, I am created object for the same class. Using that object, I am assigning the value for each variables. Okay? The value I am assigning as 10. Okay? Then using the same object, I am invoking the method display. What is happening? When you invoke any method using object, but implicit object is passing through the same method. That implicit object name is called this. Using this keyword, you can invoke, you can refer the invoking object. So, which one is the invoking object here? AM. So, indirectly I am using AM through the keyword this. So, again I can access the variable. Correct? So, simply I am printing the value of each. So, definitely it will print the value as it is. As we seen in same class, we can access all the modifiers. Correct? Okay? I am creating another class. The class name is subclass. In the subclass, what I am doing? I am creating instant for, it is the same class? No. Here I am, use the, I am derive the property of existing class. This is a syntax for using inheritance. Okay? The keyword is extends. Using the keyword extends, you can inherit the property of another class. Here the access modify is a base class. It is going to derive the property of all base class into subclasses. Okay? That subclass going to access all the methods, all the variables other than private. We cannot able to pass, we cannot able to access the private modifiers because private is belongs to the same class. Okay? Okay? So, I am again, I am accessing the assigning a value 5, 5. But I have put the as like initialization of private as into common. So, it will work. As simply for knowing purpose, I put it in a comment. Okay? Okay? If that statement appear without comment, what will happen? It will error. Private is not in a scope of the subclass. Okay? AM display. What it will do? It will again invoke the. Okay? But in this method, I am using second statement. What is second statement? I am accessing the private. Will it give error? Why? Will it give error? How many of them telling it gives error? It will not give error because display is belongs to the same class. So, it can access their own private member. Okay? So, that is why it is possible. But it will give the default value what it has. By default it may be 0. Okay? So, it will print the value as 0 instead of 5. So, we are not assigned. So, remaining variable it will print value is 5. Okay? Yeah. Yeah, it is subclass but it is in the same package. Okay? So, likewise I have created in my ID. So, it is in the same package. That is why it works. But when you comes to, it is a subclass is gives the scope of its subclass privileges as well as protected. In the under the protected roof it can access their members. Okay? Understood now? Okay? If I create, if I created the subclass as in a different package, I cannot able to access it. Okay? Do you want to see the examples? It is the same program. Okay? But here instead of display, I am having some other methods. Okay? What are the methods? Simply like I am created some. Actually I have created this for object over some, sorry method over loading. I let you explain later. Okay? These are some non-access modifiers. That is the final. The final is a, what is that? It is prevent, it is content to modify. Okay? That is the final. If you are declare a class is final, we cannot extends the particular class. So, it mean that we cannot reuse, we cannot inherit. Okay? That is the final then abstract. What is the abstract? Like basic term abstract, like simple overview of anything that is a abstract view. Okay? That is abstract. I will explain you later how abstract works in Java. Next, static. Static modifier used to create a class variables. Actually I will already explain like, what is static? The static here is that when you are mention any variable is static, that static variable or method is belongs to the class, not belongs to any object. For example, you are mention the variable. For example, s t a t is a variable. Okay? You declare that variable is static. So, that variable will share the property of property to all the objects. For example, that variable is created memory space for only one for all the objects. All object has to share the same memory space. So, what? How it will work then? It is one static variable. Okay? The value is 10. Okay? I am created object 1, object 2. Okay? If it is not static, so what will happen? Each object having their own space for accessing their own value. It may be 10 or it may be 20. Whatever you are changing blames to the particular object, it will not reflect to another object. But here, that is not the same. So, every object sharing the same space. So, through object one object, so it is like common. It is a copy for all the objects. Okay? So, if you want to access this space, we cannot access through object because it is not belongs to object. If you want to access the variable, you have to access through class name. Okay? So, it has to be access through class name. That is a static. Next one is a street FP. That is a street floating point. Okay? When you want to get the exact result of floating point, you can use this modifier. Okay? Next one is a synchronized. The synchronized is used at the aim of multi-threading. So, the multi-threading is so many thread simultaneously turns at the same time. So, there is a chance the particular code have a like not a deadlock like concurrent access. The chance of losing the data. Okay? Inconsistency will happen. So, for avoiding that, we have to keep the particular code as a synchronized. So, if it is the particular code is synchronized, the particular block can be accessed one by one. Okay? Last one is a volatile. In volatile, we can use it in a same threading thread concepts. Okay? It is changed unexpectedly by other part of the code. Now, volatile is like it will get keep on changing. So, it keep on changing in the sense. So, any like if you are using in multi-threading. Okay? All it is shared by all the thread. So, multiple thread will work simultaneously. Yeah? Which one? Street float point. For example, if you are if you are declared on variable is float. We cannot get the exact floating value. So, for example, floating value in the sense I am having a four variable float. I am doing the same calculation in different methods or something. So, there is a chance to have different values in a particular expression based on there is a number of floating point occurs. It will get change may the variable result may the expression result may be differ. For example, in a fraction point, not in the integer part, it is a fraction point. There is a chance to have a difference in a big expressions. To avoid this difference, we can use street floating point. It gives the same results for all the particular expression in all the cases. Next one is a type of variable. There is a three type of variable, local variable, class variable and then class variable, instant variable. Okay? The local variable if you are declare any variable inside a block that is a local variable. The scope of the variable is within that block. What is the instant variable? Instant variable? The scope will be within the class. The static? What is static? All instance can share it. Okay? The instant variable belongs to the particular instant. Okay? For example, I am created a put a a for the particular instant obj1 only can access this a. Obj2 cannot access this value but we can access their own variable. That is a instant variable. Static like STIT that variable. It shares by all the objects. Okay? This is a program about the variable type. I have declared two variable. One is a member variable. Another one is a static. Okay? I have created the object for the same class that is VA or by using that I am initializing the value to both. First one for first initialization, member variable I have initialized through object. For second one STAT that is belongs to the static. If you are accessing within a class, you can access the variable without name of the class. If you are accessing outside, you have to mention the class name. So that is why here I am not mentioning the class name. The proper way is that we have to mention with class name dot the name of the variable. Okay? Then I am simply printing the value of that static. After I am invoking the member function, the member function simply printing one value that is the member variable using this keyword then static. It will print both the static will print the same value and the instant variable also same. For example, if I am, okay, in that print value I have created one variable that is local. Is it possible to access the local variable inside the main? No, because that is local variable it has their own scope within that method. So there is a local instant variable that see here it was within a class. So instant variable can access anywhere within the class as well as static also. But it has to access, instant variable has to access through object static has to access through the class name. Okay? I have to raise this question before starting simple program but you may not, you also may have doubts. Now you may clarify these doubts in your mind itself. Why the main method in Java is public static void main? Just simple, first one void because it is not returning any value. So void then static, why it is static? For if you want to start, if you want to invoke any method you can access through, if it is not static it definitely it has to access through object. So the program execution is start with the main. So we cannot, before that we cannot create object. So that is why the method is static. Then public it can access from outside the class. So that is why it is public. Okay? Yeah. Okay. It is returns to JVM. Okay, okay. Okay. Thank you. So it is like JVM to what? What it is returning? Execution flow is returning to JVM. Okay, fine. So just you can note this point also. It is like, he is telling like void is, it not mean like, it is not returning any value. It is, it mean that it returning to JVM, the virtual machine that execution flow is getting returned to JVM. Okay? It is correct, no? That is okay, fine. Then object oriented principles. In object oriented principle we are going to discuss about the four things. Abstraction, encapsulation, inheritance and then polymorphism. Okay? Okay. What is the abstraction? Hiding the definitions. That is the internal functionality of an object. Okay? What is the need of hiding the internal functionality? So it is like, it is not giving the definition for an method. That is a abstract. When the case will arise, in what case you will declare a class is abstract. If you do not want to declare object of a class, so if you do not want to declare a class object for the class, what is the need of creating the class? Basically it is for inheritance. So inheritance, okay? You are inheriting. So it is not like without abstract or I can inherit. Why it is abstract? Okay. So the same we can do it in ordinary class, correct? Whatever you are explaining is ordinary class, if I am creating a without abstract, I am creating one class, I am deriving the same class. Whatever you are explaining, like I can use this, reuse the same code. What it is written in a base class, I can reuse it. Why it is abstract? That is my like. The definition of method. Same function name. That is the actual, exactly. Yeah? For example, I am taking one. Example is like a vehicle. Okay? Vehicle is an abstract class. What vehicle actually do? It can drive. It can like change the gear. It depends on the vehicle. Without gear, it cannot do the changing the gear. So likewise. But each functionality will be differ for the sub level. For if it is two wheeler, if it is the four wheeler, the four wheeler, the brand is differ. Okay? The riding a vehicle will be differ, correct? Will it be same? The base level, the implementation, the definition of the particular behavior will be differ. But it have the behavior. Each vehicle definitely have the behavior of stock and start. Yeah? Sorry? Okay? No, that actually, yeah. Actually the thing is that what I am explaining is you are telling like it is defining about the interface. The interface and it will same for abstract like also. But one difference is if particular in inheritance, for interface what will happen? Whatever you cannot give any definition for any method. You have to give a definition in the sub level for interface. The abstract also you can create the same way like interface without any definitions you can give. So it mean that all functionality will be get differ in sub level. So that defines abstract and interface. In abstract have some other features if you want to share the particular behavior in all the sub level, we can use abstract. Okay? For example, each vehicle may have the same behavior for the particular behavior will be same. So what you have to do? You no need to repeated in all the sub classes. Correct? So what we can do? We can put that implement as in sub, sorry, abstract class that code can be shared by all sub level classes. Okay? Anything else? Okay? What is the some of them like may confuse with interface? What is the interface? Correct? Or anybody knows interface? When we not aware of interface? Okay fine. So that is the abstraction. Then encapsulation. Encapsulation is like the wrapping up of data in a single unit. That is the encapsulation. The best example is class. Class is the wrapping the member variable and member function. Then inheritance. What is inheritance? As already we seen. Reusing the behavior of existing class. That is the base class. Okay? Just we want to give any explanation in inheritance. I think we have seen an example. Okay? Then polymerism. What is polymerism? What many? Many forms of the. If you want to define the same object in many form, we can use that is a feature of polymerism. It has two, one is a compile time, another is a runtime polymerism. We can call it as overloading and overriding. Let we see in deep of each. Okay? For abstract we have to use the keyword abstract. Another thing we cannot be instantiated but we can be subclass. It mean that we can reuse it. Okay? It is like a sample the syntax for defining a abstract class. Okay? So based on our requirement it may or may not be having a abstract method. If the method is abstract it mean that that method do not have a definitions. Okay? Abstract method. So as I said like vehicle. If you take that as a vehicle have the behavior of start and stop. Okay? So it is abstract. So we cannot in vehicle it is without knowing which vehicle we cannot without defining a vehicle we cannot defining a it is behavior. Correct? It is like abstract level vehicle. So when you subclass it mean that two wheeler the particular vehicle name. So it mean that we can give a definition for the particular behavior. So can we override an abstract method? Abstract method? Can it be overrided by a subclass? Overriding in the sense like. Okay? Yeah we can we can do. Yeah. This is a simple example. What is the abstract level I am giving a shape. Shape is we cannot without knowing which shape is we cannot find the area of the shape as well as we cannot draw. Correct? When you subclassed like with rectangle, triangle and circle we know the shape. How to calculate the area of the shape as well as how to draw. Correct? So that is the example. You understood now subclass sorry abstract class. You have any doubts in abstract class or any questions? The encapsulation we do not need to give an example like it is a it defines the class. Okay? And another one is the next one inheritance. Inheritance reusing the property of existing class. Okay? For inheritance we have to use the keyword that is. Extents. Okay? So we have to extends the property of the base class. Here the the class name is subclass. It extends the property of base class. Okay? You have to give the name of the base class. Yeah. Let me see the example of polymorphisms sorry yeah polymorphisms as the same. The property of object to take more than one forms. Let me see overloading. What is overloading? The overloading is a giving more than we creating a more than one method with the same name that is a overloading. Okay? So it mean that like behavior is same. Behavior may be differ. The name of the behavior is same. For example, sum. We are summing two numbers and then summing three numbers. It has to be give a features for the particular class. So that is why we are doing the method is overloading. And when it has on it has two constraints. When you are doing a overloading you have to the variable, number of variable has to be differ as well as type of the variable has to differ. Okay? I am giving one example here. This method I method name. So class name is overloading. Here created object. Object name is load. In this class having three method. But the three method name is same that is sum. What is the difference? First and second? First one differ with number of parameter and first and third it is differ with type of parameter. So okay? And for like instead of that if I am giving you another method public int sum integer a integer b. Will it be overloaded? But I am changing the return type. Will it is not possible to it is not comes under the overloading. So overloading is depends on number of it has to differentiate with number of parameter as well as type of parameter not with return type. Next one is the overriding. The overriding will be occur at the time of inheritance. So it mean that when you want to give a definition say you want to differentiate the definition of the same behavior in a sub level as well as base level. Okay? For example you are inherit the property of one class. So there is a sub class and base class. Base class have one method name is the expression. You just calculating simply take it as a sum. Okay? The method name is sum with the two parameter simply it will return the value is the sum of two variable. And in derived class have the same method the same two parameter. But it want to give whatever the value it takes as a parameter it has to sum with additionally the value 10 has to be added. So the behavior little differ. But the internal behavior is differ the behavior is same sum. So if you want to do so that time the overriding will take place. So it mean that when base class as well as derived class having the same method in a like even syntax also same like number of variable number of the type of parameter. If it is same it mean that that time the overriding will occur. I will give you an example here. So as already we seen like overriding has one method correct. The method name is sum and recreating sum here again. But without creating this I can do the same function. I can invoke the I can use the sum with the two variable integer. But here I want to change the internal behavior like I want to sum a plus b plus 10. The value will be get differ like internal behavior is different with base as well as derived level. See the first one what is happening in a first line of main I am creating object for same class or different class. Object for base class. If I invoke the method sum what will happen? Will it invoke this method the sum which is written inside the overriding class? No, it will invoke the method of base class after I am creating another object that is write. It is creating object for overriding the same class. So it will invoke the same method. But in reference I have declared both object referring the same base class object correct overriding overriding. So what is the only the second part after nu it is getting differ. What is it? Why it is differ? So what is the left side of equal and then what is the right side of equal to operator? What defines? So that is a when creating object I want to define a class name object name equal to nu keyword then I have to invoke the constructor that is the class. So what is happening? I am what I am asking in the third line I have declared over loading the reference is over loading but creating object for overriding. What it mean? Is it correct or wrong? So instead of over loading I am replacing with overriding. Will it correct? In third line I am talking about third line instead of over loading I am replaced with overriding. Will it be same? Same or different? Will it execute? What is the difference? Sorry, second case? Overriding. Okay. The same class. Okay. Okay. Okay, but in this case the sum will be invoke this within this class or base class. Base class or subclass? The third line I am asking the fourth line write.sum. Will it invoke the method of sum as sorry base class or derived class? How many of them telling it will invoke base class? Base class. How many of them telling it is a invoking derived class that is a overriding class method? Only one. Actually it will invoke the method of derived class. Actually what is object? Where the object is created? New after new using the new keyword is creating object. So here the object is created for overriding class not a overloading class that is right object right is referring the base class that is all it is only referring. I am come under the base class this level that is only referring the base level but it is not creating the object for base level. It is creating object for derived level. Okay. Only simply it is referring that is all. I will execute let me just let me see. This is over loading correct. It is visible I am executing this overload class over loading class. So it will print 7, 11.6, 13. Accordingly the parameter I am passing. So I want to run override the same correct. So let me change the value then we came to know the difference. Okay. Here what I am doing? First I am creating object for over loading. So it directly refers the base class. So definitely it will invoke the base class method sum. Next I am creating object for overriding. So it is supposed to invoke the method of same method inside the same class. So here what I have given a definition is so whatever the value comes plus 10 it will get add. If it is invoking the base class the result will be what will be result? If it is invoking base class 13. If you are invoking derived class it will be 23. The last one. What is the last one? Third invocation. I am passing 3 parameter. So what will happen here? First it is the object of derived class. So it will check whether the method is available in derived level. If not what will happen? It will goes to base level. So base level have this method with 3 parameter. So that time it will invoke that thing. So it has to give the result as 7, 23 then 17. Correct? It is not visible. It is like console I cannot increase the font. This I can but I have to go in settings. So it gives the results. You can trust me. Adding 2 values 7 and then adding values in overriding class 23. Adding 3 value 17. So that is why everyone is telling it is base class. So it means that it is actually it will creating a memory for derived level only but it is like only referring that is all. The reference we can use base as less derived. There is not much difference. What is the why we are referring in base when you have multiple level of inheritance not multiple level. The base level we have so many classes. So many classes are there. So that time by using this reference we can easily go with another sub level. For example it is a vehicle. It is a 2 wheeler and then it is a 4 wheeler. I am deriving here. So if I created only using 2 wheeler so I can only access my access level is straight to this level. If I refer through base level my accessibility level will be extend this much. So through that base level I can access all derived level. It will be helpful at the time of type casting. Understood. Type casting in the sense you have some method definition here and then method definition here. You want to you have created object for this but referred base level. You want to again you want to type cast or you want to like access level has to be changed here. That time it will helpful. That time it will be helpful. If you are using only single base level there is only one class that is not much difference. In the base level that is more sub classes then that time it will be helpful. Sorry sir I am not understanding. I am getting you. Okay. Subtract. Okay. Overriding. Overriding having a sub-tract method. But overloading has not happened. Overloading. Okay. And now I am just overloading right so it is new overriding. Yeah, yeah. Now I am just going to write all the brackets. Yeah you can. You can. But it is object. Just actually you are not. It is object level. Let me check. Yeah. It is not able to access if it is because it is referring to overload. So it can access. Just you understood what actually I was tried here. What he is asked. So actually it is like if I created the method subtract but subtract is available in where? Derived class. In derived class but I am referred to base class. So if I am referring so it is leveling the same level. The base level as well as derived level in the same base level scope. So why here the sum is belongs to derived but I can access it because I have overrided the base class method. So that is why it is working. For subtract it is not working because it is referring to base class. So derived base class. Yeah. Sorry. Yeah we can because it is x. This is actually base class the this case right is referring to which one? Base. Okay instead of overloading you want to override. So you are telling that time you cannot access 3 variables sum. You can access. Not give because it extends. So that is the feature like you are extending all property to derived class. Actual is a thread. There is a single flow execution. You can create thread by implements renewable interface as well as thread class. Syntax is like class my thread extends thread. These are the 5 states involves in thread. One is the new states when you are like creating your thread that time it will comes to new state. When you are invoking starts. Start is a method to initiating the thread. So it will comes to the state renewable. After execution starts so it will comes to it is in a running state. Okay. If any like weight or sleep interrupt occurs it will go goes to blocked state. If the execution is completed it goes to termination state. Okay. As I already mentioned multi threading if you can create multiple thread for the same class. So it will concurrently executes. Okay. And then synchronized you feel that particular block of code has to be synchronized. It can if the code is the block has to be accessed one by one. You have to use synchronized. Okay. Exception handling. So you know when you running a program there is a chance for having your exceptions. Okay. The particular case we can handle it particular case we cannot handle it. Okay. So if it is possible to handle that is a exception. If it is not handle that is an error. Okay. So the reason may be like user gives wrong input for example divided by for example I am taking two value I am dividing the values. If you giving the values 0. So at the end of execution only it came to know we cannot divided by 0. So that time exception will catch and then do that action. If this is a hierarchy of exception that is a first one is a throwable class. Under that there will be chance of there is a error as well as exception. Error we cannot handle it. What is the what are the chances of error? Sintax error. Then the memory is now out of range like JVM memory is like gone. So there is a error we cannot handle it. The exception we can handle. The exception may be come in two scenarios. At the end of compile, at the end of execution. At the end of compile it is a compile time exception and there is a runtime exception. The compile time exceptions. So at the end of compile itself the compiler will inform you this is a chance of exception. So chances are there. For example I am declaring one file. I want to read one file in a particular location. So it will tell you the file may not found because you may give wrong file name. So you have to handle that exception. So at the end of compile it will tell you. And then IO exception like divided by 0 may occur based on your expressions. So these are all some exception may happen. For SQL database may not found. So those those stuff that is a compile time. Runtime is at the end of running your code there is a chance. For example you are creating an object. By using that object you are referring you are invoking one method. But at the end of creating object the object is null. So but using that null you cannot you cannot invoke any method. So there is a null referring a null. So there is a null pointer exception also there. And then number format exception. So these are all some runtime exceptions. Index out of bound if you are referring the limit other than the maximum like array index out of bound. So these are all some exceptions in runtime. In exception handling there is a three important terms are there. There is a try catch and then finally try is a block of code the chances of having a exception. You feel that the particular code may have a chance to have an exception that is has to be written in a try block. In catch block if the exception happened what you have to do the action that is a catch block ok. The based on the exception type you have to you can extend n number of catch blocks ok. Then finally, finally it is not mandatory it is optional. But it is like preferable to use when you want to close the database ok. So most of the you are developing a code you definitely have to know this ok when you are opening database in try block definitely how to close it in final block only. Why? For example, if you are opening a database you have some code and then you are closing a database in a try itself. So what happened after open you have written some code if that code have a exception what will happen without close it will jump to catch. So database remain open if the same code execute by n number of people in web what will happen imagine number of based on number of user number of like hit it will be get unnecessarily database resource will be get wasted ok. So you have to close database in finally only you have to use it is mandatory ok. Last one is a constructor like constructor if you want to in slice value for an object you have to you can use constructor ok. Now you an example the constructor name should be same as class name you do not have a written type ok you can use the constructor even you can overwrite the constructor ok overwrite in the sense you can write n number of constructor based on the same overwriting the constraints will be same here for example number of parameter and then type of parameter ok these are some reference you can refer it. I can share this ppt next one is jsp ok before getting to jsp we talk about servlet ok. Servlet is a same java class but it has the implicit HTTP request and response object ok. So it can handle the request and response it come from HTTP ok. If you want to use you have to extend the package yx.servlet this is servlet I will tell you architecture of servlet. So example if you are in you are giving a request from web browser it will go through web server it will be transferred to where servlet container the servlet container having all the servlet classes based on the request type it will send to the correspondent servlet ok. Then if the servlet want database access it will access it and then response will be send back to web browser through web server ok this is architecture works in servlet jsp java what is that java server server page ok. Actually it is a HTML page with integration of java code ok HTML page integration of java code that is a jsp it has to be the file has to be save in extension dot jsp and you want to include any java code it has to be with the tag is a tag you have to use it for including a java code ok. This is a jsp environment this jsp execution environment there is a two phases one is a translation phase another one is a execution phase translation translation is like jsp code may or may not have a java code correct without java code you can write a jsp page if the page having a java code so it has to be translate into class ok. So, what is happening the jsp page having a java code it will comes to translation phase it will what will happen it will translate to servlet ok the code whatever the code it will be translate to servlet the servlet is like java again java class it will transfer to class by using compiler ok using java compiler it will transfer to class file that that class file will be using jre java n time environment it will transfer to the particular web page it will go back to browser if the page does not have java code directly it will comes to execution phase it is a like static content correct so there is no need to comes to translation phase java and then jsp having the this three life cycles one is a init then service then destroy init and service will be exude only once ok init will be at the aim of creation destroy will be at the aim of like end of the life cycle of the particular of jsp or servlet. Service is a method it will give the service like get based on the get post whatever it depends the service type ok ok in jsp tag as I mentioned if you want to include the java code in jsp page you have to mention in a the tag it has a three type of tags in jsp first one is a expression then scriptlet then declaration ok the expression if you want to any expression and the result will be printed as it is the result you want to print the result as it is in HTML page you can use expression the code the code we can call another name is scriptlet in the scriptlet you can write the whatever statement you want like condition statement like looping statements so whatever thing you want you can use it then declaration you can declare variable and methods whatever you want you can declare but you have to use the proper tag accordingly ok I will give you an example then you came to know this is an I am using here the expression simply I am printing the current date and time using the method date it is belongs to the package java.util ok so what is happening simple HTML code in the HTML code I just am writing one like string in a body like hello the time is now so I am for I am taking a current time using the java method date ok so it will print next one scriptlet here what I am doing I combined java as well as sorry I combined java code as well as HTML code here the first line is java code so I have written in where scriptlet what I am doing here I am taking a random number using the math class ok using the method random I am getting random number if I am the random number is less than 0 I will print hello sorry have a nice day else I will print have a good day ok you have any doubts on this no no how to use it simply you can use it as is it as it is like you condition for loop and then you can combine in between both java code as well as HTML code in a jsp page declaration here I am declared one variable that is a access count that is a integer likewise you can declare method also ok you want to declare a entire method like public void some print display or something you want to declare a same method you can declare within this tag yeah you can do it is a prop actually it is a proper way of accessing it has some standard to access is a proper way but you cannot declare a method you can in a scriptlet you can declare a like variable but here you can declare a method also and then comment as it is all the priming language have the comment you can give a comment for given description about the code but there is a like we can use HTML comment also as less jsp comment there is a two difference HTML comment will be visible in a visible to the user and then jsp comment it will not display to the users so display in the sense it will not display in a web page in web page you can see the source code in source code it will not display the comment of jsp comment ok next one is the directives it is a three directives page directive include directives and then tag live page directive is used to you want to like do any page action like you want to define a error page if any error happened for the particular page you want to navigate to error page we can use it as less like you want to define the priming language then you want to I will give you an example then you get more elaborated these are the page directives for example here I am defining first one is a content type I am giving the content type whether it is a the page is page is content is HTML content or XML content and then whether the page has to be flesh automatically or not then error page if any error happened in the particular page where it has supposed to be navigate so the error page it will when error occur it will navigate to error page then import if you want to like import any predefined functions not only this if want to use your existing class which is available that method you have to refer in a jsp class sorry jsp file you can use it for example you have a Java class the Java class you have a methods you want to use that method here so first you have to import that classes for import you have to use that tag okay that is a page import equal to the class path next one is a page information if you want to give a information about the page you can give then session whether you want to maintain a session you know page or not okay I will give an example like session all the things the includes simply it will include the pages mainly you can use this for header and footer for example in a web pages you may use same header and footer in all the pages header and footer will be common in all the pages you want to know need to write the same code each and every page simply you can import those pages header and footer pages in all the pages this is the action tag for action tag is like a it control the servlet engine based on the action for example if you want to forward to some other page you can use jsp forward and then want to include you can use jsp includes but did this include will be execute a dream of this a dream of it works a dream of execution time but already we have seen include in a page that is a it will execute a dream of compiling the param is a one action tag if you want to navigate a dream of for example forward if you're forwarding a page that time you want to pass any parameter you can use this tag with the name and value of the parameter so this is a very important one in a jsp there is a jsp default object using this object you can just more interact with Java code as well as you can use more features in a jsp first one is a request it is a object of HTTP servlet request for example if you want to get request HTTP request okay so HTTP request in a sense if you are transfer one page to another page at them of navigating one page to another page if you are passing any like parameter you can get the value of the parameter using this request object as less you want to get the query string what is a query string query string for for example if you are invoking Google okay we are searching any text in a text box what is happening that text will be passing as a query string so it's like after cosine mark it will give a variable name and then value so there is that is called a query string if you want to access that value you can use request object as less you can you can get the uri of the particular page as less response response is a object of HTTP servlet response class for example if you want to redirect then direct to particular page you can do as less you want to like catch should not catch any data in a browser you can use the content type what kind of content is like HTML content or XML content same we can use it session what is the session you are knowing about session it is very important session simple when you are using when you are accessing a mail session is occur for example when you are logging to the web service till logout one session is maintained okay if the session is there you can access inbox you can draft the mail you can whatever thing you want you can do after logout the session will be get let's try you cannot access the same inbox after session is destroyed so we are maintaining one session for the users okay so how the for access scope we are defining access scope for the particular application out for example you want to print any data in a USB you can use out how that print those stuff application it is a servlet content servlet context it is a object of servlet context as already mentioned like servlet servlet as a container correct so you want to access using this object all the servlet data you can access that is a what is the application object and then exception this is for error error information you want to use it for error information session objects I will go with some detail about jsp session object it is like a I will give you an example before going to example I will I will tell you the important method involves you know session the first one is a set attribute set attribute having a two parameter one is the name of the parameter and the value of the parameter you going to set okay if you are set this value you can access through your till this session is destroyed you can access this value anywhere in a web page okay that is a session if you want to access you have to use the method get attribute you have to pass the parameter as name of the parameter session name then you want to remove the session you have to use session dot remove attribute you have to pass the session name as a parameter you want to destroy all the you want to remove all the session variable for the user you can use session dot invalidate for example if I am creating a name as a session again I am creating a age as my another session you want to destroy all the session so you can use session dot invalidate it will remove all the session yeah entire session of the particular user which user have the session own session only it destroy for the particular user you know an example I am creating one HTML page okay what I am doing here yes I am created one form inside form as a two input tag one is a text another is a submit okay when I am doing action on submit button the action will transfer to which page in action I have mentioned create session are jsp simple HTML page with action whether it has any Java code no okay in create session what I am doing body of the and simply I have created one what session variable the session variable name is what my name just do not look into the first line okay I will explain later why I am using that okay first I am setting the session dot set attribute my name the name value sorry so first I have to explain yeah the first one is like I am getting whatever action I perform whatever the form field will be transfer to request object using that request object I am getting the name of the text box whatever value I am entering using this I can get the value you can see it here what is the name of name field of what is the name of the text field my name I am using this name here to get the value inside the text box so by using that value I am creating a session but the session name is my name okay after that I am redirecting to response as I said already by using response you can redirect the page so response dot send redirect I am redirecting to my session at JSP this is a my session at JSP here what I am doing I am checking whether the session is available or not in this page okay how to check if I am getting how to get the session variable get attribute name of the parameter okay if it returns null it means that session is not available it gives any value it is available so I am checking if it is null if it is null what it has to do it should not stay on this page it simply redirect to login page if session is available I want to print the value inside the session okay for example I am simply typing this URL will it go I am simply accessing without login page I am accessing this page will it open no why I am not come through create session dot JSP in create session dot JSP only I am creating a session so I am direct without that I am directly coming here so it will not work so this is how works in like mails all the things like after logout is it possible to goes to inbox no because the session is destroyed okay so if it is there it will simply print the value with suffix welcome then after I have one anchor tag logout as it will goes to logout dot JSP in logout dot JSP simply I am what I am doing removing the session using remove attribute then redirect into login dot JSP that is my session at JSP now this I am before login I am trying to access this page see what is happening redirecting to this page because there is no session so this coming here so I am in the same page not a problem so after logout so it will come here again I am trying to access the page so it will again go here sorry we have done in logout see no for desktop you have to use I am using remove attribute see here in this page remove attribute in logout so when there is an anchor tag it will redirecting to this page in this page simply I am removing the removing the session then redirecting to login this is application object this application object it has one feature session can be shared by the single user the application can be shared by all the user okay for the application for example I am we have one web application okay if you are created any value any session variable the session variable belongs to the particular user who is created only one user can access that value in application is not like that for example I am Rajavail I am created one application variable okay all the users using that application can share that value using the same name okay that is a application variable it is same like how we are creating a session like set attributes get attribute and remove attribute okay here I am using it simply I am getting a one hit count the variable name is hit count I am checking whether it is null or zero if it is null I am printing welcome to my page then I mean slice the value as a hit count is one if already the value is set in application it was it will print you the value welcome back to my website then increment the count it will finally it will print the count value actually it's last it will go with the five minutes only okay I think already everyone most of them knows about a JavaScript I will tell you only it's very basic okay it's like a JavaScript is a scripting language it can be right inside a HTML okay for handling a event of if any heap even happening in a HTML page it will be handled it will execute in a browser the code should come inside the tag script okay and then with the attribute type it's a client side validation you can do client side validation for example if you have a form whether the form is form value is empty or not whether email is correct or not so these are some user side validation this validation you can use it and then react based on the event when you are doing any event it can handle it as less you can read and write HTML element dynamically okay and then you can handle the session using cookies this is a sample script I have written a inside body I have created one parameter like paragraph tag after that I mention a JavaScript this JavaScript simply what I am doing this is before that I let you know like get element by ID is a one method belongs to the document is this usually to get refer any unique element by using is unique ID okay so you can get the value inside that element as well as put some dynamic content on it by using get element by ID so it is a e b as less I should be capital okay for refer for referring the content of the paragraph you have to use the attribute in a HTML by using that I am simply putting the current date okay this date is JavaScript method okay not belongs to Java JavaScript also having a method default method that is date it will print you current date and time and then JavaScript can be anywhere in a HTML the best practice is to write in a header inside header tag because it's easy to like debug the error as less we want to edit it and then you want to extend more and external JavaScript you want you can write separately JavaScript you know separate file okay in this one what you have to do you have to write we create one JavaScript file inside you have to write all the methods blank to JavaScript okay that one you have to extend in a particular HTML page by using script same attribute already mentioned and then you have to do another at another attribute that is a src you have to mention the path of the particular JavaScript okay and the simple thing like Java is semicolon is not mandatory but the best practice you have you can use end of the statement you can use semi-quad by using semicolon you can write in single line itself n number of statement you can write it's simple command comment is same like see single line command and then multiple line comment then these are the pop-up box available in JavaScript that is a alert confirm then prompt alert is simply whatever the message you are giving inside alert it will alert confirm it will give you the same but it has a two button one is what is that yes sorry ok and cancel if you press ok it will return the values to else false if you press cancel it will return false ok so if you want to do any action based on the button press you can get that value using confirm but alert box will not and then prompt it will print you message with one text field whatever you are entering to text field that one will return back ok so for example here prompt please enter your name if I enter any name so it will you can get it based on that you can use that name for your further action see this is simple like in body I have created two button one is a alert confirm prompt on click of each button I am invoking the method I am alert I am confirm and I am prompt in alert simply alert message confirm I am checking the return value if it is yes simply I am printing the return value then prompt same it will print the return value also these are some common used even on load so even so even is like for example if you want to a demo of even for here one event is there what is it even for the button on click on click is an even at the time you want to do any action you can do here what we have done simply display some alert messages so likewise you can do based on even you can do the action so these are some common even on load the few pages loading is on load and unload as less on focus if any like event is focused element is focused for a text field is focused when you move to the you are any for if you go to the particular text box that is focused you come you go to another text box that is blur so blur is like focus out okay on change if you are changing any value this on change submit and then mouse over mouse down mouse out on error key down key up I'm sorry these are some evens you can do any action on this event I'll give you some example what is the record field validation so if want to get the value of the text field what you have to do get element by ID ID name and then value I'm checking that value is empty or null if it is if so then what I have to do first enter the first name first name must be filled out and then returning here email but what is the email email supposed to have to special cat what are they dot and at the rate okay and then it has to be appear in the particular location at the rate should be after some text after at the rate also there should be some text before dot okay so what I am doing I'm getting the the position of particular characters those characters getting the value what which is enter in a text box then after I am getting the index of at the rate as less dot that is I am taking the last dot index okay because in a before at the rate also I can give a email ID with dot okay so here I am checking if at position is less than one so it means that the email ID start with at the rate it is a not valid next condition dot is less than at position plus 2 so what it mean dot position is appearing like it may appear followed by at the rate or after one character the it mean that I am telling I'm fixing the like limitations like after at the rate there should be minimum 2 characters should be there before dot comes okay then another condition what are they the email ID should not end with dot okay at least it should be after dot it should be 2 character if so if any of the condition is not satisfied it will print not a so it is satisfied it is not a email ID then cookies you can store the the locally some data in your mission that is a cookie the dom is a document object model by using that you can dynamically create a element and then remove the element and then you can timely put content get the content all the stuff you can do with document object model okay for example just as I we said before like using want to put any data inside a any due or paragraph you can use get element by ID then you have you can use in a HTML as less you want to find number of the element for number of images in a page you can use document dot images dot length so these are some document by using document object you can do all the stuff dynamically you can set the document title as just get the document title is the last one CSS on JavaScript you dynamically you can you may aware of CSS cascading sale sale sale see what is the use of this you can design your page like with a number of tales like changing the colors then size of the elements all this stuff you can dynamically do with document object model for example here I am doing I am changing the background color of the particular element I am referring the element by document at get element by ID then the attribute is a main attribute here that is a stale it defines a stale of the particular element what is the property we are using the attribute like background or font or display based on that we can give you can change the stuff I will share all the people it is due we can refer it and then if we have any doubts you can mail it