Can we override static method in Java? | Core Java Interview Questions | Mr.Srinivas

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone welcome to novice technologies this is say much so in this session we are going to discuss one important FAQ in Java so that is can we override a static method in Java application question is can be override static method can we overwrite static method is a simple question so first of all we should know so what is overriding right we already aware of this so there is a class class is a parent class or to understand more clearly more clearly for example class to take one mobile suppose the Samsung Galaxy mobile we are taking they like say Mumbai so in the galaxy mobile so there is a method suppose the camera method is then the void so camera some logic kisseth so means what it is a 12 megapixel cam so simple logic we are writing so first of all what is the method overriding so first we should implement inheritance concept between the classes extension is very very important next means what extension to galaxy is just consider Samsung edge it is the extension of a galaxy Mobile galaxy and suppose here in a galaxy the camera is there the functionality is already there so whenever you are extending then edge will collect that functionality from galaxy to edge but whatever the functionality which is available whatever the functionality which is available so that automatically they will come to that extended class but suppose if it is not sufficient to the updated version the camera 12 megapixel is not sufficient to the edge then we can rewrite the logic wide the same is a camera chimera and of course we are rewriting the logic so means what we are not changing the name and we are not changing the input type and all so without the means what a same name and same signature of a parent class and subclass so both are same the method names so that is what we called a method overriding but here the concept is all about the static concept is all about the static sir what is that a static what is it static see suppose in a class in your class so if you take any method is called a static method static the void is m1 static void m1 with some logic we are taking with some logic we are taking and here so static in the sense is water which is common for all the objects in the hierarchy right and here it is we are taking one more it's a child class is the child flash is extending from parent so means what extending means what is updation right so what are the things we are updating means what only specific things we are updating the common things we will not update in the next version because you are saying that it's common for on whenever it is common for all if you want to update or if you want to change the logic you can change directly here right directly define here and modify here the modify is nothing but his update reason it is a static method static method is common for all it is available to all suppose if you if you update here imagine sir I want to update here I want to update here then it will become specificness then it will become a cific then it will not become a common you are saying that in java the static means what it is just a synonym of a common it is just a synonym of common here you are saying that it is a common so if it is a common and if you want to update it you please update in the parent class only and you please bench means what we should not supposed to update in the child class whenever you update in the child class then how can you say that it is a common so it is different and it is different so then here it is the main functionality of static is missing so so static members means static method means it belongs to a particular class that you cannot overwrite but you can access commonly read only non static members means what it is a specific that you can update but static methods you cannot update okay a reason reason so to maintain this common functionality word so whenever you want to update you please update in the parent class only please don't try to update in the child class if you try to update in the child class then how can you say that it is a common it is a specific to child and it is a specific to parent so common the word is missing that is the only reason static methods you cannot overwrite in java application okay so thank you thank you for [Music]
Info
Channel: Naresh i Technologies
Views: 39,545
Rating: 4.8292685 out of 5
Keywords: Can we override static method, override static method, static method in Java, Core Java Interview Questions, Core Java, Core Java Training, Core Java FAQs, compilation error, Java allow overriding of static methods
Id: MuEenxrkDwU
Channel Id: undefined
Length: 6min 3sec (363 seconds)
Published: Wed Mar 01 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.