Java Interview Questions and Answers | Java Tutorial | Java Online Training | Edureka

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so welcome friends my name is Shawn and we will be discussing some into equations which are quite crucial and important with respect to Java so guys once again this is Shawn on behalf of Eddie Riga it's been a long time that I have been associated with Adriana so I'm an exemplar Espenson RND so more or less into startups as well and it's been more than ten years for me that I am into the Java so I am a technocrat more or less so love to explore Java Android and I somehow we are you know very well connected so I'm also an aluminized with bricks Palani so worked across various nation there is a South korea-us Canaanites expected trap so this was a little bit about me let's understand the market of Java for support right so we're going to first of all understand that how Java is useful and thereafter we'll see some various topics where we will be understanding some integration so Dow has been great in number one and TOB popular programming languages index so even if you browse on the various job in different sites sites will be able to see that Java has been rated as number one programming language so it's used by 10 million developers and over 15 billion of devices they are powered by Java and Java is nowadays very you know popular language especially in terms of when you come up with a mobile application development with Android right and Big Data Hadoop again so any D th boxes again Java is there so Java is used almost everywhere now and having a fair information or the Java is always a better thing if we compare the Java job trends we can see the posting in India versus posting than a US so approximately 50,000 job postings as off for 15 March 2017 in India and approximately more than 7,000 in United States right so that's like the average Java job data which we can put up it's not from the various different prototypes right so mockery and indeed Lynden that you can see right so depends now but we have taken up the maximum from the indeed right so quite quite few good you know job postings ever labels now if we talk about the distribution and the salary trends again Java outshines right and 62% of the Java development jobs are available in the market right we got various different rules in which the people can fit in we got engineers architects programmers lead analysis and consultants right and we got one or two two four six dollars per year as in you know the average salary for a Java developer if you can see there are various statistics available for the salaries the gain guys this data has been you know mine and it is as of 15 Jan 27 2014 5 in the interview rounds right other than that will be taking on to the topics one by one so will take on two hoops that's like object-oriented programming structure and this is the core of your Java then we got Sollux so they are the basic components when you are going to write your web application then you got Java database connectivity where we'll be understanding and we'll be introducing to few of the concepts in the market this set to the database connectivity then spring as in the framework of frameworks right so we'll be discussing what is spring and emphasis will be on the NBC part that's like model-view-controller and lastly we'll be discussing the hibernate so hibernate is going to be the backend framework right how you can opt for hibernate instead of JDBC we'll we'll just see some comparisons and see various interim equations coming into that part so let's just start with something known as the basic questions which are asked to the candidates in the entry process so the very first is the difference between three terms just like dedicate JRE and JVM so as a Java developer you must have a fair knowledge what exactly are these three terms right so that let us understand now so Java Virtual Machine is basically an abstract machine it's a software which is already provided by the platform so it provides the runtime and vomit whenever you are writing the Java source code it gets compiled into the bytecode so JVM is back there which is going to execute your bytecode now other than that you got GRE which is our runtime environment now it's basically where JVM is gonna use the JRE so they are a set of libraries required by the JVM in order to execute your cool JDK is one development kit required by the Java developer so it consists of various KPIs for you through which you can write your code so just one instance right so JDK will contain your various packages coming into for example Java dot IO Java dot util all these API is the set of library the information that comes from your Java development kit other than that it has various tools also available for example Java and Java C right so Java C is a tool which is used for compilation whereas Java is for the execution of your bytecode so these tools are also part of dedicated so let's switch onto the next question what is synchronization this is one of the hot favorite questions whenever you talk trade so we do have this term known as synchronization so synchronization is something where multiple threads if they going to access the same object right so there is only one resource which multiple threads they want to excess you need to come up with something known as swing to migration so guys what is synchronization here will take up one example let's say we want to book a movie ticket and it's going to be one seat which has to be booked by multiple people right so let's say one corner seat in the last row has to be booked by multiple people so multiple people over the web will treat them as multiple threads they are looking on to a single object on a single resource act like the roll Gnostic right so whosoever will first of all try to block that feat will be given an excess and no other person can thereafter block that feat so synchronization is very much in line to this concept when you got multiple threads which are going to work over a single object you need to use a key well known as synchronized with the help of which you will be able to acquire the lock on your objects so synchronization is a process it's going to keep all the concurrent rates in the execution to be in a synchronous mode one after the other the lock acquisition going to come up into action synchronization will avoid the memory consistency errors due to any inconsistent view of the shared memory let us understand the difference between processes and threads now so synchronized words came up and we started off come to the next rate so let us understand what exactly is process and what is the thread not so guys in order to come up with process and trade let's just have one visual coming in let us say you got this layer as an operating system right so we'll say that this is one operating system it can be any who is now right it can be Windows Mac Linux any of the flavor so when you want to run the program what OS will do which will create a process right so this process will be created by the operating system whenever you are supposed to execute your application so other than that what it does is it will also give you some you know storage space with RAM will come into action right so further the RAM can have various data structures are coming into it for example you can have the data being stored in the power of stack or the heap right so that's like the storage context let us say I got one program which I need to execute so whenever I am going to execute my program so the running instance of your program over the operating system is nothing but it's a process but in the process we have one guy known as main threat so main trait is what this is the guy which will execute some instructions or you can say some sequential tasks which you mention in your main method right so whatever the statements you are writing in your main method they are nothing they are these tasks which are executed one after the other via main trade within the process so guys a process is running instance of your program over the operating system and a thread like a main thread is running within the process so we must understand threads are available within the processes and processes are running on top of operating system there might be scenario that a particular task like I'm going to highlight this task over here so this might take a longer time right so let us say this particular task we take a minute off so because it's going to affect the data from the server now so in this context right so these three tasks they will be blocked right so when I am talking about these three tasks the yellow state so they gonna get blocked now so what we can do we can bring down one more thread and we'll say that this is one user thread or childhood so we got various for the terminologies for this guy right and we'll offload the heavier task over here of the main thread to the user trip in this way what we are able to do is we are able to outsource the heavier tasks in some other thread and we will be coming up with a concept of concurrent programming that is what we want to achieve now right so let us son who has happened over here guys so let's see this part now so process and thread there are two different concepts but we must understand now any executing instance of a program on top of your operating system is nothing but it's a process so on operating system we got multi processing whereas straight is something which is a subset of the process now so within a process you got my people trick so multiple processes on OS level multiple threading on flosses level then you talk about the communication so one process when it wants to interact with the other process we call the processes as inter process communication we are threads within a process they can directly interact with each other when we talk of the control statement so processes can only exercise control over the child processes whereas threads can exercise considerable control over the threads of the same process any change in the parent process will not affect the child process whereas if there is something where the main thread is getting affected the other user threads or the child's rate then might get affected if you talk of the Mamre structure so processes they're running the separate memory space each and every process will have its own mammoth space whereas trades don't share the same memory space which is being allocated to the process by the operating system so that once again process is controlled by OS whereas threads are controlled by the programmer in a program right or you can say by the process itself if you talk of the dependency level processes are independent we are threads they wanna get dependent because if you can rotate this image right over here so we created this user thread and there is a dependency that this task has been outsourced to this user thread by the main straight so dependency of the main thread over the user thread relies and vice versa right so it can be based on a logic fever so let us move to the next concept now so the next fundamental is what exact is a wrapper class now this is also one of you know the hot favorite tuition which is always asked what is the wrapper class what is meant by the term boxing or the auto boxing so let us see this part right so wrapper classes up they are the way bill we can convert the Java primitive into the reference types that's like the object so each and every primitive site has a wrapper class defined and it's in by default they are available in java dot nine package you need not to import any package so for boolean we got boolean right for cal we got character and for ain't we got integer for double so on and so forth life so wrapper classes are the means by which you are able to convert your primitive into the references so let us understand what exactly is this conversion of primitives into references let us say I got this I as 10 so we call this guy as a single value container because I can continually one value it's not an object now it's a primitive type you want to convert this primitive guy into in all day usage interior is signed new of integer and you mention this guy I as a part of constructor so what we have done we have boxed so it's like constructing the object now constructing the object so that's what we have done guys over here right so this particular statement over here is known as boxing on the other way around when you say in de assign iref dot int value so this concept is known as unboxing right extracting the value from object so you must understand this concept over here boxing words unboxing which is achieved with the help of wrapper classes other than that you can also save integer KF assign I so this is known as Auto boxing right so this instruction is translated internally by the compiler as in integer t ref assign new of integer where we got this guy known as I right so this is Auto translation you need not to write the whole statement so you just mention the partial statement or the implicit statement we call it as Auto boxing and if you write down let's say L assign TF right so this is known as Auto unboxing so important question again what is boxing which is unboxing and thereafter what is part of opting words in Auto unboxing so the major reason why we do boxing or unboxing is to convert primitives in to the objects now if you are talking about object oriented programming structures right so we are always thinking of objects now so if you are able to convert primitives into the objects it means that you are strictly and truly following object oriented programming structure so we got one way of doing it and now you can also pass by reference the primitive so that's one more way of coming up like why you do a boxing part so we can pass the variables by reference is now right because here you are getting the reference is no object all right so let's come back now to the next question number five that like what are the keywords final finally and finalized and what is exactly the purpose of it so they are and now the three different keywords right so even the final term is something which means the last thing but they are a different meanings in different contexts now now finally the kind of a constant so to mark a variable is final you can't change its value so here if you can see a very small snippet right so a is the 1000 and you are try to change its value the compiler will not allow you to do so so final is a keyword where you are able to mark your variable as constant you can also mark your classes to be final in that context you cannot inherit from that class you can also mark the map search to be final in this regard your methods they will not be overridden so final can be used with three of the concepts final ads of variable finalize a class and final average method finally the other context where we use it with the exception handling techniques now so what exactly is the place where we will be coming up with finally so many a times when you are writing the exception handling code with a fly and a catch Clause there might be a scenario whenever the exception will come the statements mentioned within the try block they will not be executed below the statement where the exception will come right so let's say there are ten instruction in the price and on the fifth instruction in the try you get an exception so below six seven eight nine and ten instructions they will not be executed you need finally block to mention such instructions which must be executed either exception comes or it does not so finally if that piece of block which will be executed whether the exception is coming or it is not coming for example if you want to close the database connection now exception is there or not but we would like to close the connection at any cost right so you mention all such statements and yours finally block so the next part is finalized so guys finalize is the kind of a destructor so whenever the object will be removed from the memory by the garbage collector so this finalized map that will be executed so you can explicitly try out for example where you can say system dot DC right and you need to just mention your references to be pointing to the null and thereafter your finalize will be executed so you can just have a small example on this right so what I can do I can just demonstrate this so let's say we got this class known as finalized demo right and I'm just going to make this method finalized over here so I'll say C so object finalized right so here we go now what I will do I will create the object or finalized demo so I'll say find like them FD reference assign new off finalize demo so here we created an instance and thereafter I will say be raised to go as null it means it is not pointing to anything now so later I'll say system dot DC so this is called the garbage collector and it's going to destroy the objects which are no longer required so now you can see over here so let me run it as a java application it says objects final why is it coming because it's acting as a destructor call so anything that you want to do before your object is removed from the memory right you can write it into the finalize method all right so let's go to the next concept it's a difference between spring buffer and spring builder right so before we jump on the spring buffer and spring builder we must understand they are both similar concepts when they are compared with the spring class so string is immutable version we are spring buffer and string builder they are the mutable version right so let me define this spot what is meant by mutability versus immutability consider you got this string str1 which is a new strength having holo and you got this one mode I known as spring builder you say sighs new string builder and you mention hello similarly you say string buffer let's take this guy as a buffer you say buffer assign new offspring buffer again follow so I have taken up these three strings let us say fer builder and buffer and now what is next I will be appending the data in this print now so you see SCR dot contact so in spring you need to say the function as one cat so I will say hi and similarly let us concatenated plus a builder dot append so in the build of the function which we use is append and same goes with the buffer so buffer and builder they are quite similar now later when I will do a C so on STR and similarly the builder and the buffer part let us say builder and then finally the buffer so the buffer here we run the port you see one major difference over here is that you get hollow so nothing happens when you concat the data into the SCR right but in case of builder and buffer the data is concatenated this is why because strings are immutable whereas buffers and builders they are mutable this is also one of the very beautiful query first of all so guys buffer and builder they are the mutable sequences whereas spring it is immutable you cannot change it even though you are going to perform an operation so what is happening over here whenever you concatenate the data you will be getting a new string right so you need to store the data into a new string so concatenation resides the data coming out as a new string the old string is not changed so significant difference between buffer and builder now we'll be discussing shrink buffer operations are straight ship so it means that by default when you are going to use buffer it will be synchronized you need not to worry on top of multiple all conference reading now whereas builders it's not resist sling buffer is to be used when multiple threads they are going to work on the same string whereas builder is supposed to be in a single city environment other than that builder is quite better as compared to buffer over the performance part because there is no synchronization overhead so you can just try to write out this snippet over here which will be able to help you to come up with a timing difference and you will be able to see that builder will outshine the buffer in terms of performance all right so let us understand the difference between heap and stack so stack and heap they are two memories which are very much famous when you talk about the Java Runtime right so dollar runtimes the RAM we got these two major data structure stack and heap so first of all let us see how the stack and heap will come into action right so let us take one example guys so I'll just remove this snippet or like so let us understand the stack and heap into action when we are talking about the RAM allocation so this Ram will be divided into two parts the first part is the stack and the other part will be the heap so this circle is representing the heap memory so both of them are a part of RAM now so it's a good read of structure they are part of Ram we got stack and heap so let us understand this point of stack and heap how the data will be stored and where it will be stored I just take up one basic example from the Eclipse now whenever you will be creating an object so for example finalized demo I said FD R if assign new finalized demo this is known as object construction statement right so this is object construction statement so here what we are doing we are trying to create an object with the help of new operator and to be very much more precise I'll take one class like point right and we'll define some x and y as attributes within this class point right and I can have one function like show point which can just display me the data of point so I can say point is plus the value of X let us say a - plus y right so that's like a pointer so how are we creating the object of point now same way you created a finalized demo you say point p1 reference assign a new off point so how this statement will be represented in the mammal slice for this statement to be represented in the mammary what will be going into the stack what will be going into the heap let's have a close look onto that partner p1 riff over here will reside into the stack like this right so this guy is p1 right it will create on some memory location so let us review its 4001 it will be a hexadecimal address but I am just assuming it to be one address over here as 2001 so this memory location this container p1 ref is created out over here what is next the next part is an object which will be constructed in the heap which will have two compartments the first compartment is your attribute that like X&Y and the second compartment goes like the methods show point so this is like the attribute and the second compartment is for your mappers now what is happening over it so this object has no naina right so this is having no name on the heap you don't have any name for this guy but you can definitely have an address over the map let's say this is six thousand one so this object is constructed at six thousand one so p1 rip will have the address of your object and this guy p1 riff is doing nothing but it is pointing to this guy six thousand one so we say p1 rep as a reference variable because it is referring to the object available at six thousand one it's not a kind of a point or not right in order to prove this approve this concept we can just say this out of p1 rest when I will do a six out of p1 r if let's say p1 rip is plus the value of p1 rep now I'm going to run the code you will understand that p1 rep over here is showing me some address of an object of type point right since we got in the package code or I'd wake up it will that go dot area dot point and memory location so this is the memory location 785 to be 9 to 2 which p1 rep is holding for your objects so now once we are good to go what is available in stack what is available in heap for this instruction right so there is anything for which you use the new operator that will be constructed in the heat so heap is that memory location where we use the new operator and new operator is used to create the things dynamically when I use the word dynamically it means at runtime it means anything which is constructed dynamically at runtime in your program it will reside in the heat right so that's what the new operator will help us to do now let us have some more defenses between stack and heap so guys stack memory is used only by one thread of execution without heat memory is used by the all parts of the application if you talk on the excess level objects stored in the heap are globally accessible there a stack memory cannot be expressed by the other threads memory is likely foe whereas the heap memory is basically are the pre structure not right so the memory management is based on the generation associated to each object so here what we try to store at the data is in the form of key value pair so each and every object will have a hash code now so that next is a key for your object then you talk of the lifetime so we got existence until the end of execution of the thread whereas heat memory will live from the start till the end of the application execution and your garbage collector can anytime free this may be space if you talk of the usage now when an object is created over the stack so now please guys in case of Java every object is dynamically constructed so there is nothing like objects being constructed in the stack right so we are just giving a general overview of heap and start over here not typically in line to your dollar these are the general difference is now in Java your each and every object will be constructed dynamically in the heat space not in the stack space so in the statue if you will be getting the references to the objects now right so guys whenever an object is created it is always stored in the heat space and staff memory only contains the local reference variables which are pointing to the objects in the heap so let us move towards the next base equation that's like the difference between the ArrayList and a vector so these are the two data structures these are the two collection API is in the Java dot util package so both of them are quite same the very major difference is that ArrayList is not synchronized whereas vector is synchronous right when your data structure is not synchronized so the performance will be a bit more better as compared to the other one so that's why your ellipse will behave faster in terms of performance as compared to your vector if an element is inserted into the ArrayList it increases the size by 50 percent whereas vector that don't do it so but they just double the size of it sorry write an ArrayList does not define the increment size whereas in the vectors you can define how much size the vector should increment when it has reached its limit other than that RLS can only use iterator for traversing whereas in vector write expect hash-table vector is the only other class which can use in number relations as well so you can enumerate over the vector with the help of enumeration we can also you know it breaks in the vector so that's that's like some of the differences which are highlighted over here similarly the other collections of hash map and hash table so this is again a relevant question which is asked in the includes many times as a basic question so hash map and hash table again the first difference is the synchronization right and your hash tables they are synchronized whereas hash map they are not synchronized hash map allows a null key and another value whereas hash table is to a null pointer exception if you try to add an ulti or on a lolly other than that since a hashmap is not synchronized it's gonna behave faster as compared to the table and we can make the hashmap as synchronized by calling the collection synchronized map api so it's not like that we cannot mock the hashmap it's English we can come up with our own logic failure right because hash map Traverse can be done through a grater whereas table can be enumeration as well as iterator hash map will inherit abstract map class whereas hash table is totally working on the dictionary class now the next concept is the difference between equals and equal to operator now this is one you know as a new Java developer many times will do this thing will do this big mistake by comparing the strings with a equal to operator so unlike your other languages here you need to use the equals mapper to compare the spring not right so they'll let us understand this concept first of all I just try to demonstrate it by writing one examples so let us say you got one string if you are one as new string so just recently we had this discussion that this is an object construction instruction so F here one is a reference variable whereas a spring object will be constructed in the heat so STR one is having one address right so let me write down this thing F here one is a reference variable it is having the address of an object similarly I'll create one more SPR to write so X here 2 is also reference variable it is having the address of some other object the difference over here which we need to understand is that there are two different objects which are containing the same value hello right so objects are containing the same value hello and str1 and str2 they are the two different references and having the different value so that's why if you want to compare it using equal to operator right so it's gonna say STR one let me just finish out the program and in the else part I'll just say not of equal to right now you will observe that if here one is not equal to X Fiat the reason is very similar because you are comparing a references now so double equal to we are comparing references right so that's one important depends for us to understand now when you need to compare the objects you don't use double equal to instead you use this master known as dot equals right so you say let us compare the strings using equals method so here I will say equal and not equals so we don't compare strings using the equal to operator that's very receipts it's one big mistake you compare the strings with the equals method equals master is not comparing the references it is comparing the values within the objects right so that's what we are able to understand comparison of references versus comparison of value so you can take up this program guys over here if you can see right just go ahead and try to run this execution we got one more program over here let us predict the output for this program so in the main method you are calling the map third one with the input as 11 so you pass this 11 over here from here you are invoking the map set to bypassing 11 into 11 and in the master - you are passing method 3 which is division of 11 and then in the method 3 you are subtracting 11 and finally in the maps at 4 you are adding off 11 you guys finally we will be getting the result as 1118 right because 11 into 11 it's going to be 121 divided by 11 it's going to be - 11 it's gonna be 0 plus 11 again gonna be 11 to try out this program right and 3 to 8 if you can get the same output or not so these are some of the basic questions right highlighted by us which are very important and crucial from the introspective next we'll be jumping on to the object-oriented programming structure now this is one key area which company or an interviewer is looking and expecting as a developer you should be quite good on these concepts because the advanced concepts or any of the application development model it relies heavily on object-oriented programming structure so let us see what we can have in the object-oriented programming structure the very first question as in question number 12 is the difference between abstract classes and interfaces so let us see some of the differences again guys this is quite theoretical information right but I would like to take one very small demonstration on abstract class versus interface but it is pretty important to have a very fair knowledge and this concept is linked with your runtime polymorphism so let us understand this concept so I am going to create one class shape and we'll have this master known as the draw why it so let's have a draw method and you say see so drawing the shape now this is something which even we teach in the traditional language like C C++ I mean a native languages so this is the same concept carried forward we got a shape class and we got a draw method so what you want to do you going to create the object of shape as a sign all that is in shape s and then say s assign new of shape and then you can say s dot dot so the output is very much simple you get the master drawing shape but I want my shape to be either as circle rectangle or polygon right so what I will do I will just come up with a class known as circles so I'll say this guy circles shall extend something known as shape right and in a similar way also try to come up with something on a rectangle and lastly I'll say a polygon so shape as three children ah and each and every child will be redefining the draw method with the respective shapes right so here we are now this is very well understood that whenever you going to redefine the method so the concept of overriding will come into action right so this is overriding and now if you say Circle C and C assign a new of circles and you say C dot draw you will always get going the circle because overriding has come into action what I want to do I don't want to do this concept right it's a basic concept now that whenever you will create the objects of size always the definition of child will come into action as a concept of overriding what I want to do I want to say reference variable belongs to the parent and the object belongs to the child now this is known as polymorphic statement so how it is a polymorphic statement now the guy shape s is pointing to circle so shape is now behaving after the let us assume that now this instruction is equated it's very very quickly the equation is true reason is that circle is also a shape circle is a child of shape so technically their type is still not right so I'll say s dot draw so I am saying s dough what you going to observe is you get drawing the circle of it is very well true because there are two definitions one belongs to the shape other belongs to the circle and when you say F dot draw you will be getting drawing a circle so you will be giving the preferences to the children over here and the paint definition they again want to get overridden what I'll do now I say s is now a new off rectangles why'd you pay s not draw and then you say s is new of polygons and then you say F not draw so every time you are able to achieve s dot draw drawing the different different shapes right so this is what we call having runtime polymorphism the same master draw over the same reference variable s we are able to draw different different shapes dynamically at runtime right this beautiful concept is known as runtime polymorphism right and what we need to understand from here is that the guy draw in the shape method is useless having this concept over here that s is a new shape so having the object of shape and executing this guy s dot draw makes no sense it's not a pretty good sense right drawing a shape makes no sense ship has to be circle rectangle or the polygon so what we need to understand from here is we need not to have the object for this class and we need not to have the definition for this guys draw so you can change the architecture of your program and you can bring down one more class shape mark this guy as abstract and Mark the mastered within your class also as abstract so an abstract class is a class for which you cannot have objects now you can't create objects right so here you can see it's an error other than that the master can also be marked as abstract which means you need not to have definition so guys when a class is not as abstract you cannot create the objects but runtime environment will create the object right so see so I say shape is constructed very very important difference which I am going to highlight today so when you face the constructor over here right so you are able to create the constructor it means the objects can be constructed for the shape but you cannot create it runtime environment will be able to create that you cannot create if you will try to create it it's going to give you an error right so the same problem statement is solved drawing a circle drawing a rectangle drawing the polygon but before the construction of the child object the parent object is constructed by the runtime environment so we say this is object to object inheritance right so what is happening over here inheritance is happening over here from object to object so the parent object is constructed by the runtime environment and then the child object is created so abstract class is a class you cannot create the objects but the parental environment can do so and it can have abstract method which have no definitions for no definition for this guy who has to define these guys the child has to mandate redefine the definition for the draw so if the child is not defining the door mastered it's going to show an error so let's try to see this so you try to comment out this code you can see now it is giving you an error so if there is n number of abstract methods in the abstract class you need to redefine them in the children now we can understand this part that this shape has helped us to improve the concept of runtime polymorphism but this is again which is like a parent is writing some rules which are supposed to be defined by the children now there is a relationship known as parent and child relationship so flat class shape is been extended by the circle it's a parent-child relationship for example the parent is giving is depth on making a rule that breakfast has to take place at 8 a.m. in the morning now the children they need to define this rule and they can come up with their own definitions ok we'll come up with a break pass at 8 a.m. and I'll have snacks I have bread and butter or anything right so that's like a parent and a child relationship and from basic shape class we came to an abstract class shape with some you can sit there were some problems over here that we didn't want the objects to be coming up and we didn't want the draw maps words to take place wait so we achieved a better way of coming up with runtime polymorphisms to extract lapis now I will come up with the best way so I say one interface shape with the method as white draw so guys this is the best way to achieve runtime polymorphism now so what I will do I've got the extent sheet but I will say implemented now this is the difference which we must observe over here so rather than doing an extension I am doing an implementation and in the interfaces by default the methods are public abstract so it is by default like public abstract white draw and in the interfaces if you will observe now so this constructor is significantly an error it means that neither you nor the runtime and warmint can create objects of shape right so it's an error right so for the interfaces neither you can create the objects nor run-time environment can create objects it means this is not objects to objects inheritance there is nothing like parent and child relationship over here what is the problem over here this is the kind of traffic police or the police department is imposing the rules on us to we're a seatbelt and now we need to define that rule right so traffic police is imposing a rule to follow the traffic light and it is up to is that how we define that rule it's not a parent and a child relationship kind of concept it's not parent objects and the child object concept but I hope you got the example and you are able to correlate the fundamental between the interfaces what is the abstract clapping now since this method is by default public so in order to redefine you need to always have a higher express or the same exit right so this is how you have achieved one more refined way of runtime polymorphism right guys so what we have understood let's come back and now summarize the whole concepts so a flat class and interfaces they are the two different concepts but we can accomplish runtime polymorphisms with both of them one being the parent other one being one implementation right because an abstract class can provide complete default code or just the details that have to be overridden whereas interface it will not provide any code so it's just the signature there cannot be any definitions in the interfaces greater the abstract classes they can have the definition so we can only extend a finger abstract class whereas a class can implement several interfaces so this is not multiple inheritance it is multiple implementation right moving ahead now abstract classes can have even regular methods there are interfaces they cannot have now the instance variables in abstract class they can add this but an interface it cannot have any instance variables its variables are by default static variables right if set classes you can use public private protected so on and so forth whereas an interface by default the visibility is public or not right so it is by default public somehow if you mention nothing it is by default public now so here we can have constructors they cannot have constructor it means that you don't create the objects but runtime environment will create here neither you can create nor the runtime environment entry substrate classes are faster as compared to interfaces they are slow because it requires extra indirection to find the corresponding map third in the extra class right so that's what we got some of the theoretical differences of the practical implementations so polymorphism I hope is now very well clear right you guys are polymorphism means more than one form where a mobile phone can serve the purpose of camera remote mp3 player and alarm clock so on and so forth right so polymorphism can be characterized into two parts one is at the runtime one is the compiler so why runtime polymorphism is there you are coming up with this parent and a child relationship again we saw this map example shape circle polygon and rectangle right so what what happened in the runtime polymorphism you create a parent class and then you create a child class child class must override the method of the parent class and thereafter you do an up casting by saying the reference variable of the parent can point to the object off site and whenever you will execute the method you will be able to see the math word execution happens for your child so what is the difference between overloading and overriding so guys overloading is concept linked with the compile time polymorphism whereas overriding is linked with the runtime so the definition part method overloading means that the same maps in name should have different inputs or the different arguments right every time they must be different now so in macro writing the signature should exactly be C so a return type will not make any difference but here everything should be exactly same if you talk of the behavior method overloading is basically adding or extending the method behavior whereas overriding is changing the existing behavior of the map and all right so here we are trying to add the functionality here we are trying to change the functionality for compile polymorphism versus runtime polymorphism different signature versus same signature and when you are talking of the inheritance it may or may not meet inheritance in method overloading whereas overriding is only linked with your inheritance so this is one significant difference guys if you can see right so this we have already observed the overriding part but in the overloading part if you can see over here the add method with the two inputs of type integer and two inputs of type double so this is one significant example right so guys this is like overloading and this is like oh right right so you can just I think this is done wrongly so overriding is at this example overloading is diffic map alright so if there is any method which is private or static so can you just try to override such a method where the answer is no you cannot do so so private method will not be inherited so it makes no sense to override it or to redefine it whereas static method it belongs to the class so you cannot override a static method right so it's basically what we call it as in a class to class overriding which is known as hiding right so here the concept is known as Heidi so if there is a static master in the parent class and if you want to create a method in the child class to override the static method it should also be static and that concept will be referred to as hiding now so what is multiple inheritance and does Java supported you guys multiple inheritance is one class extending more than one classes so this is not supported in Java so if you can see there is a diamond problem which comes into action that if there is a class a right and B and C class they are inheriting the a class and there is a class D which is getting inherited from B and C so two copies of a will be coming into the last class so this kind of problem is not solved in the Java it needs the virtual concepts to come into action since there are no virtual keyword or any other or you know pointer support available in Java so we cannot solve this problem now right so Java multiple inheritance is not supported so one more very now over here right what will the output of this program so if the parent is having this method foo which is not less static and one map third bar which is a non static method and there is a parent-child relationship where we are hiding a method workspace overriding a method and you are executing these method calls right so guys the output will be so since if you can see over here so this parent dot foo and child or food and parent dot bar and child odd bar right so you will be able to get all these four outcomes I am full in super in child then child and then child right so let's try to execute the code and get the behavior similarly we got one more program so guys this is where we got multiple constructors and you created the object for the e so by default default constructor will come into action but this over the reference function call will execute the constructor over here and this over here will execute the constructor over here so you will get how are you then hollow and then the height right so this as a constructor execution will happen over here as a function cost so we get output in the reverse order now right so one more program guys what's one of the output for the program so it's basically one miscellaneous sub program where you got a block and a static block so if a block is executed when you create the object of a class where a static block is executed when the class is loaded into the memory so the idea is to define you guys the role for the static block and a normal zone so a block over here if you can see is executed when the object is constructed and static block is executed when the class is loaded into the memory so this I to run this program and come up with this output guys all right guys so now let's understand subjects right so this is where we're gonna perfu with the Enterprise Edition concepts of Java so we have left out the core part of Java now we are moving into the advanced part of Java so service is also one of the core concepts when we talk of the Enterprise Edition of Java so let us understand what exactly is a service right so that's like what is a service so servlet is one Java program which is executed over the server now that's like one very basic definition - what exactly is a service what happens now whenever you are writing an enterprise application you need to have some code that is executed by the server so if the client is sending a request via HTTP or the HTTP request it comes to a server and the server will execute your Java program and it's gonna send back the response to the client now the client can specifically de browser or it can be a mobile application on any other kind of a client base right so Java servlet is a server-side technology which will extend the capability of web servers by providing support for dynamic response and data persistence we got Java X dot servlet and da exhorts servlet dot HTTP package which provides the various API is for writing the server program now any servlets program should implement the servlet interface along with the life cycle methods where you can manage your code snippets as most men applications they are expressed using the HTTP protocol so we got a class known as HTTP servlet and we got a corresponding hierarchy for the same so over the web we use two of the major methods one is the get one is the post so what is the difference between get and put so guys get in post we got two major methods how we can send a request from a client to the server other than that we also have various of the masters like sports delayed pray stone and so forth so these are the two important methods yet is when you need to have limited amounts of data which can be sent right because the data is sent as a part of the URL mouth so post is when you have a large data and you need to send it across the body so it automatically comes up that the data is not visible as a part of the URL and it is more secure in in terms of force requests right so security is more because the data is knows not exposed in the u.s. other than that you cannot bookmark the food but the get Stanley bookmark we want idempotent verses known idempotent so where is what is idempotent when you send a request you get a response you again send a request you again get a response and you compare the two responses whether they are equal or not right so idempotent so the guide get is more efficient right and it is more used than the post right where light depends right so efficiency is like get is more efficient undoubtedly but it depends upon a requirement where you need to use what okay so let's say you want to do a sign-in so obviously we need to pend the username and the password to the server and you cannot send it by across the URL even though you can send it but you need to encrypt the data before you send it right so that like the differences between get and push now what is meant by the session management right so guys session is one term which means that time interval between the client and the server so we have techniques to manage the data within the session so that's like the fashion management not so what are the various methods so number one we got the user authentication then the hidden form fields cookies URL rewriting and we got HTTP session API also to manage the session so session is a conversational stage between the client and server and it can consists of multiple requests and responses between both of them now HTTP is a stateless protocol you cannot manage and maintain the fail so that's why we need to use some fundamentals which we can come up with this right so guys every session will have a session ID which will be passed between the client and the server during the request and response and you can use various different techniques so to name few we have mentioned them right now we also have two API is known as servlet context versus servlet context so what is the difference over here so servlet context and context is where we need to extract the data which is stored somewhere as in part of your death dot XML deployment descriptor so we will consider that part now so soviet config is a single object where soviet context is on a global level now right so it's like a local parameter associate with a particular servlet whereas we got a global parameter so both of them are the key value pairs right mentioned within the web dot XML files whereas a servlet conflict so you mentioned the data within the servlet whereas service context is mentioned out of the servlet acts in the server program you can use the API you get soviet config and get servlet context and thereafter on the basis of the key you can retrieve the data right so for example shopping cart of a user is specific to a particular user so you can use servlet context we have to get the mind type of a file or any kind of a global level order a variable you can use the servlet context now what is a possible life cycle of a services are really important when you talk of servlet Skype right so service they got five stages when you talk of the life cycle right the first of all the sorbets will be loaded then it gonna be instantiated initialized then a request will be sent to a servlet and then finally the servlet will be destroyed so we got in it service and destroy as a pre life cycle callbacks involved when you write the servlet program we got three or API is now in its service and destroy what is requestdispatcher if you want to share the data from one server to the other servlet evenly right so we got this guy known as the request dispatcher which can forward the request to the other resource now the other resource can be possibly a servlet or an HTML file or a JSP files and we can do so using the two different methods one is the forward method other one is the include map so what happens over here is when you send out the request from the servlet one to servlet two when you use the forward method response generated from the servlet two will be sent back to the client in case of the include method response from the servlet two as well as the servlet one will be appended and then sent back as a final response to the plane now we got requestdispatcher coming up with the forward and include in B two differences so guys one of the important conflict associated with the subject session management is cookies right so what exactly cookie is so cookies are the textual data which gets stored on the client machine and this data is sent from the server so data is stored in the local machine of the client guys let us see this part right so if you can see over here I will show you this thing so when you open down the settings of your browsers right and you try to say cookie right so if you can see over here so you get these options of cookie coming up over here content setting you can see cookie so allow the local data to be set which is evenly recommended so that cookies are the textual data which gets stored on the machine and you from the server can diffuse the master known as get cookies why to read out all the cookies and you can create a cookie by using the APA cookie itself it is a hashmap key lupe cookie see one fi new cookie with the key and the value right and if you want to add the cookie to the clients machine you just call the method add cookie over the response object so the next part is the Java database connectivity so as this deals with the database connections not right so Java database connectivity we got the first thing as JDBC driver so whenever you want to create a connection you must have a driver right so guys driver is the layer which will help us to interact our JDBC API is with the database there are four major types of drivers we call them type 1 type 2 type 3 and type 4 driver it goes like DD BC ODBC bridge drivers native API driver which is a partial Java driver then if you want to come up with a client-server model you got Network protocol driver and lastly you got the pure kind of a driver CIN driver the fully Java driver which we'll be using to interact directly with the data so Java app it's going to use the JDBC API and the JDBC driver manager will interact with the driver and drivers will further interact with the drivers for the databases a libraries and so and hence this whole channel of communication will be established so what are the various steps to connect to the database in Java we use JDBC and there are some sequential steps which you need to perform so that we can perform all the crude operations so what are we not so there are five sequential steps which you need to perform so as any of the database whichever you are using right so you need to come up with the documentation over their website write what is their driver class name what is the URL so on and so forth anyway let us have a look onto the snippet now the first one is registering the driver which comes through the API known as class dot for me so here you managed to write the driver type for driver or any other driver which you are going to use then you need to create the connection this is created with the help of an API known as driver manager so you say driver manager dot get connection we need to pass three things over here the first thing is the URL where your database resides so if it is on a local boat you mention the hostname to be the local loop and you managed to write the port number and the database name then the username and the password for your database thereafter you need to fake create statements over the connection once you have created the statements thereafter you will be able to execute any of your SQL queries but in the finally block you must close your connection right so this is important that you managed to close your connection regardless or whether exception is coming or not coming so what are the different JDBC API components so guys we got various interfaces and slashes coming into the Java JDBC package should we got gamma dot SQL package and many of the libraries if you can see the API are mentioned over here in the interface part we got connections statements prepared statement results it resides at medidata database metadata and Colleyville statements so all these are the interfaces so connection is used to have a connection statement to execute the sequel statements prepared statement is also used to execute the sequel statements but if their statement if different from the statement in terms of how you are going to substitute the data into the sequel statement so here we use something else wildcard characters as question mark right results it is the received data from the database and the data about your retrieve data is known as resultset metadata and the data about the database is known as database data data column of statements are used so that you can execute the stored procedures of your databases and some of the few klappas which are mentioned in the right hand side it includes driver managers that you use to get the connection so be Rome and Phillip are the two API very can manage the binary large objects and the collector large objects Oh binary large object means the audio files the video files right whereas kilo means the textual pipe then the type will define what are the various types equal exception is exception in the jdbc if there is any connectivity issue or any other synthetical issue or any different kind of equal issues which is going to occur at runtime so sequel exception is the class to get the error form now what exactly a JDBC connection interface be like right the connection interface is the one which will maintain a session with the database so here we can use the transaction management logic which means a Tommy sitting so Tommy theory means that all and everything should happen at once so let us understand so connection is one important interface with the help of which we can manage the transaction for the transaction let us assume I want to transfer the amount from one account to the other account so there needs to be two possible sequel statements which are supposed to be five one will be the updation in my account that will be deduction of the payment in the other account again and updation queries it will be the addition of the payment so these two ways should be fired at once and if any one query fails the other query should be rolled back so for the transaction management VR the connection you create the statement and thereafter you can come up with the auto commit API where you can mark it as true and then you can use the API is like commits and rollbacks to manage your transactions so close the method where you are able to close the session with the database right guys so there is one more possible difference between three of the API is that like execute execute query and execute updates so guys execute query executes update and execute these are the three different API all the behaviors are used to perform the sequel operations over the database but query Packard is always focused to door retrieve operations if you can see now select operation right so whereas your execute update method it's going to perform the DML and the DDL operation insert update delete create and alter of the table right whereas execute method it is able to perform any kind of operation of so this is typically used to retrieve the data here the data can be modified whereas EDD method any kind of sequel statements return type of these methods they are different now so results it will be returned from the execute query methods here we will be getting some interior output and here we'll be getting some boolean output this matter is used to execute only select queries so non select queries and here both the Select and non-liquid right guys so that likes are the JDBC part right so how we got various API is available the java database connectivity but we need to come up and understand there are the five different set so you start from loading the driver then creating a connection writing the statements executing the statement and finally moving on to the closing of the statements so the next part is the framework of frameworks that like the spring frame so if you know this if you have a hold on your spring framework guide so it's like you are done with almost everything now right so one of the most important framework in the Enterprise Edition of Java let us see what is spring framework so what exactly is spring right so spring is an application framework which focuses on a concept known as inversion of control for the Java platform so many of the great technologies they are built looking on to the architectural model of the springtime or even the Android how the UI part is linked with the layout part so that concept is again adopted from the spring pattern right so it is one of the patterns which focuses on IOT that like inversion of control so the framework core features they can be used by any da app for building and Enterprise Edition applications one of the major advantage of writing a Spring Framework app is it's lightweight it is having an integrated framework architecture where we can use it to develop any kind of an enterprise app in Java right so it's less on a memory it's high on performance and it contains various frameworks available within it to which you can write a multi-purpose enterprise application so by what is all are the modules available in the spring framework now so spring framework has various modules to start with we got the very first layer as the core container if you can see this four layer so whole of your spinning framework is dependent on this core layer so this core layer focuses on something known as inversion of control and dependency injection so we got this a spring context dependency injection then AOP is aspect-oriented programming this focuses on how we can fulfill cross-cutting concerns then the database module of the Spring Framework includes Dow JDBC and ORM as in the design pattern so now the data access object so here we can write the Dow patterns to access the database we got JDBC support we also got the hibernate or the Orang support which is object relational mapping the bed module of the Spring Framework can help us to write the web application where spring MVC is one of the major Lee used frameworks in the market now so model view controller we our model represents the data container you represents the UI or the presentation and controller represents a business logic event so let's now write so spring MVC is one of the very important concernment it comes to develop the web application and we got various web services out in this module itself let us move on to some annotations which are used in the spring configuration so guys there are various annotations now which are used in the spring framework now add the rate required right so it's like what is the input which is required auto wiring for your dependency injection what happens pre destroy what happens forced construct right so before the object is finalized just after the object is constructed what is the resource what is the qualifiers these are some of the spring annotations which are used for the configuration purpose so what is being in spring and what can be the different scopes of the bean in this thing right so guys I pick up one very basic example earlier to mention this concept right so let us take one example so I got this spring demo available with me with all the jar files available out here we got this employed in dot XML file so just give me a moment right so all right so here you can see now we got this employed B so this is one XML configuration for the Spring Framework so we got co dot edeka dot employee as a class right and here what I am able to do is to define the property value tags for my speed right in the employee dot java I can fix basically a bean or a poodle so what the bean class being class is a class which will have the attribute along with the setter and the getter right so all the sector gates members are also there in my client class what I am going to do I am just gonna use this spring container and thereafter I will just extract my employee optic white so just let me do this part all right so I got the reference of the employee in dot XML and in my class I got this em bean one so I will just say M being one and thereafter I will do a see so off and white let's try to run the boat and you can see that the data over here is coming up as in ID name and salary but I have just over righted this two string method out here so along with this and also suppose to do a super dot two thing right I will do a backslash and at a super dot P shape so now it will show me the data object object as well as the reference variable and is pointing to the address it is showing me the address as well to the object now so the beam is extracted from the spring container right so there are various scopes available now for example same and been one in my client if I try to get it again right so let us try to say get of being again why it as in m1 and m2 let us say this is n2 and this is n1 right so I will closely observe one difference I mean one similarity that every time then you request this guy get been for the mbean one you are able to receive the reference to the team optic scope of the being can be mentioned over here using attribute on a scope and here now I am going to mention it as prototype you can see we got this guy as a prototype now when I run my code again you will find one significant difference that here the reference is coming out to be different it means now by default it was giving me the singleton as a design pattern but when I change the scope to prototype every time I am requesting the objects of n being one from the spring container it is now constructing a new object and returning it back to so by this is what we got as in what can be the scope of your beam in the space so inversion of control container have various scopes now single domain only single object which is by default so prototype means you can have every time a new objects request means one object for entire request session means one object for entire session and globalization means one object for entire global session online application levels so how is it being added to a spring application so guys you use this pad known as deal you mentioned the ID and then you can have the properties having key value pair right so what is the role of dispatchers servlet and context loader lifts nur okay dispatcher salat is acting as a front controller in the spring MVC so many times I will call it as a reception is not so what happens any requests when it's going to land up to your bed application so this guide dispatcher servlet will dispatch the request to the corresponding resource available on your there application so it's going to act as a receptionist in your program now whereas contact loader listener it's a listener which will give you the event callbacks when the context will be loaded it's like startup and shutdown of the web application context in the spring rules now what is the difference between constructor injection and setter injection so before you come up with a constructor injection and the setter injection you must understand what is dependency injection so guys let us understand this flow once again I am having one class employ right and there is one more class known as address so employee can have the name employee can have some salary there will be definitely one employee ID and employee can also have an address right so I will just say an address to be yes Adi so what we can do we can create one constructor of an employee in this way right and here you can say e ID goes like 101 mail goes like let's say John celery goes like 30,000 and address both like some new address right where address can have some address lines then you can have some city you can have a state and lastly we can also have some kind of a zip code just mentioning some parameters over here now what will happen over the client spot you will be writing employee assigns new employee so whenever you are creating the object of employees this becomes the concept that the constructor of the employee will create the object of the address we can see a significant dependency now when you are creating the object of employee within the constructor of employees the object off head rest will be constructed we say this concept as high dependency or you can say we got a higher value of coupling now we need to reduce it right so you need to bring it to the lower level so you need to take it as low coupling so what I will do I will not use this technique I will take let us create one more constructor and pass the address as an input right and thereafter you can say address assign it or you can create a setter you can say set address and you can say address and here you pass this size so guys in these two approaches rather than having a single employee object you can now create an employee object you can create address objects separately right you need not to be dependent upon the employee objects and later you can pass the address object or you can say employee si new employee and a dot said the address and you can pacify a so we want to reduce the dependencies or we want to come down with the coupling parameter we created this logic out here so setter injection and constructor injection are the two terminologies laid up in order to justify these two terms now wait so let us open up our presentation once again and look on two constructor injection versus setter injection so there is no partial injection so setter injection can lead to partial addiction here we need not to override the setter property but here the constructor property in case both the things that defines so you can create new instance if any modification occurs so you need not to create any instance if there is a property change so better for too many properties better for you properties so guys depends upon your choice but constructor and second injection we have the two key concepts to bring down your dependency to the lower levels now what is auto wiring in spring so many times when we are writing this dependency injection programs you can perform this injection program based on the name right for example you can mention this auto wiring tag and you can pay by name so you need not to now write an explicit injection logic it will be mapped automatically for you so there are various modes through which you can have an auto wiring coming into action so know is the default mode it means you don't specify the auto wire it means here nothing is enabled so automatic is not enabled so when you mention by name it means you take the setter method and you mask the day car corresponding to the name PI type we'll use the type of the attribute and constructor will inject on the basis of the constructor so how can we handle any exception in spring MVC framework right guy so there can be exceptions now when you are writing the program right so swing em with frame work can help us to achieve robust programming concepts to these possible ways number one controller based so you can define an exception handler method in your controller class itself you can have a global exception handler where exception handling is a cross-cutting concern to AOP right and then you can have a handler exception resolve so any spring beam which you have declared in the dispatcher servlet application context that can implement handler exception resolver which can thereafter be used to intercept and process any exception which occurs in the MVC system and it is not handled by the controller pass so you can use the areas or different concepts out there if you can see add the rate exception handler annotation so that you can specify that this view will be used to display some addicts all right so some important annotations again in the spinning framework guys we got a dread controller a great path variable qualified configuration scope request mapping response body or the wire service and up fix right show all these annotations they are quite important conflict and you must have a fair knowledge on all these right for example at the rate auto wire so either you can configure it in XML file all you can use a notation so XML files they come up with the inversion of control concepts where as annotations you need not to have XML file you can use them directly alright guys so last in the spring framework we can also have Spring Framework coming up wizard database connectivity either through Jerry's if you are to hibernate or any other framework not right so spring and hibernate they can work together we have some foreign models available within the spring framework and we got an API known as hibernate template if you want to come up with the spring and JDBC you got JDBC template Yeah right so guys spring over a module will help us to integrate hibernate framework into a spring application and spring for EM also provides the support so that you can use paying declarative transaction management you can use annotation then you can perform the action sock so now we will be on our last concept that's like the hibernate which is a back-end framework based on object a relationship map right to get let us see what and all we got in the hibernate now so the 44th question is what is hibernate hibernate is an orange which is object relationship mapping it's a framework now where you just mention your Java objects and you forget about your database tables so by what we want to do we gonna write down some mapping files as an internal configuration files where you will be mapping that it's attribute in my object in my class will be a column name in the respective relational tables so hibernate provides a reference implementation of the JPA java persistence api right and it makes a great try 700m tools where we got the benefit of loose coupling now I hope you got the meaning of loot coupling we're dependent we have been reduced to the maximal level so hibernate configures all the flexible and can be done from the XML configuration as well as through annotations programmatically right it provides us both the ways now so what can be the benefits with the hibernate trimmer so guys hibernate will eliminate all the boilerplate code whereas in the traditional approach you need to mention and write various code snippets and you need to write the relationship mapping the cache management everything is you know eliminated when you use hybrid now so this framework will provides us XML both as in through configuration files and annotation all supports you JPA that's like java persistence is like now hibernate was a very powerful language that like SQL which is very much in line to SQL but you need not to learn it it's more simpler than the SQL even now if scale itself is very simple language you got more simpler language than the SQ that like it's us guys it's an open source project from the Red Hat community and it is used worldwide and very famous especially for any large enterprise application your hibernate framework is one of the ideal choice is not now any database vendor specific feature hibernate is suitable because we can also execute native sequel Qin so I Burnett is not just that we can use it's a native API and you can't do anything out-of-the-box you got to execute the sequel queries also with the hibernate one of the most significant features of the hibernate is the cache management so hibernate provides three levels of cache through which your performance of the database operations they're going to get improved now so what is the architecture of hibernate dies so hybrid of having an architecture in a very similar fashion guys we got a database on top of database we got a various you know modules coming in for example java transaction api's we got java database connectivity and thereafter we got j and di that's like java naming and directory interfaces on top of it we got the hibernate api so configuration api will read the xml configuration files and it will help us to create a session path tree session factory will be used to create the session and session is one api which maintains and creates a connection with the database using the transaction api you can use the commits and rollbacks features and query API will head you to create one query and retrieve the data criteria is one API which will help you to mention the criteria for example you got restrictions to you know manage for example greater than less than or equal to so all these are criterias when you are trying to retrieve the data in the java application you just write a POJO class you just write a bean and you give this objects to the hibernate and hibernate api is there going to manage everything for you all right we got the get method and the load method in order to perform the retrieve operation so let's see the differences let's say we don't have a record available in the database so load method will throw an exception that my object not found exception whereas the get method will return a null event the object is not found so they get mastered will always hit the database whereas load method will not hit the database right in case it's not there and you going to get a real object not a proxy object whereas load will return you a proxy object so gate should be used if you are not sure about the existence of instance now so let's say that the record is existing or not I don't know so you you get if you are sure about whatever you are going to extract from the database it is existing you can use the load method so there are now significant differences between hibernate and JDBC types this is one of the major query between you know as in a part of interviews so why hibernate and why not JDBC what are the defense is what are the advantages that you should be opting for hibernate now if you are writing a very small app right you need not to go on the hibernate hibernate level is required when you're writing an enterprise app right where you need to save the time and you don't want to do a rework and there are various other defensive so let's have a look onto that now so guys first of all you need to write a lot of code when it comes to JDBC we have hibernate you have limited instructions you mentioned right - except orts all the Association inheritance collection mappings where in case of JDBC APA you need to write all those logics so one-to-one one-to-many many-to-many all these mappings they are available as a support in the hibernate hibernate will also give you the transaction management implicitly whereas in JDBC again you need to manage that one now JDBC API they will throw sequel exception right so it's a tend exception so we need to write a lot of try-catch block code when you are using this a JDBC but hibernate will internally manage this try catch block for you we got hql which is object oriented programming whereas JDBC you need to write the native sequel queries hibernate will automatically give you the cash management for better performance in three levels of cache whereas JDBC you need to manage it yourself so by default hibernate performance is higher as compared to the JDBC path so lastly hibernate will provide an option where we can create the database and the tables too but for the JDBC these existence should be there before you dump the data other than that one of the very significant feature why hibernate or DD BC is if you want to switch from one database to the other database it's going to be very complicated with the JDBC but in case of hibernate we got a configuration file you just need to change the parameters in the configuration file and you will be able to shift from Oracle to my sequel or any other database to any other database of your choice so guys that will be all so we just wish you all the very best right the team advaitha and we shan't you guys wish you all the very best thank you very much so any questions any queries and your feedbacks they are always welcome I hope that you enjoyed the session and once again Oh the very best for your interviews thank you very much guys I hope you enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply to them at the earliest do look out for more videos in our playlist and subscribe to our Eddie Rica channel to learn more happy learning
Info
Channel: edureka!
Views: 1,423,316
Rating: undefined out of 5
Keywords: yt:cc=on, java interview questions, core java interview questions, java interview questions and answers, java interview, spring java interview questions, java interview coding questions, java developer interview questions, java interview questions and answers for experienced, spring interview questions, hibernate interview questions, servlets interview questions, java tutorial for beginners, java training, java course, java online training, java edureka, edureka java, Edureka
Id: oYXivKMSEqM
Channel Id: undefined
Length: 101min 5sec (6065 seconds)
Published: Mon Mar 27 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.