I am 4yrs experience guy of Automation testing... But was very confused about abstract keyword... But after watching ur videos, I m very much clear ... Thanks for providing such contents.. it's helping for freshers as well experienced guy 🙏🙏🙏
I understand how to create the Abstract class and method, but why we need to create the abstract class and method. What is use, e can directly use the child class method no need of parent class.
If any class contains at least one abstract method, it needs to declared as an abstract class. That doesn't mean abstract class needs to have an abstract method. Abstract class can have: 1. static variables and static methods. 2. instance member variables and methods. 3. Constructor which are called when a regular method inherits the abstract class and by constructor chaining parent constructor runs before child constructor runs. 4. final member variables and final regular method But not final abstract method as making a method final means it can't be overridden and abstract means it should be overridden. So it becomes opposing.
Sir, what you taught was very clear but the real life example of why we are creating abstract method was not very clear.. Can you take another example and explain the need for abstract method.
Sir, Your videos are very helpful. I been following your videos for quite a lone time. Sir, in this tutorial and some previous one too, I did see when you're describing inheritance by a simple diagram, the arrow always comes from the parent to the child class. But Sir, are we not inheriting from the parent class? So the arrow must be from the child class to the parent class. Am I missing something ? Thank you For your effort though.
Suppose ,maine abstract super class me kuch variable declare kiye aur unhe inherit karke ek sub class me lau to wo sub class abstract banani padegi to unako use karneke liye mujhe unko sub class me firse define karana padega to mujhe 2bar define karke kya faida.... Mujhe ye kehanahe sir ki 2bar define karne ke alava me ek bar kyo n variables ki define karu....
hello sir! thank you so much for making this kind of videos, these are very helpful. Sir I have a question regarding this lecture and that is, we are making abstract method in an account class that is abstract class but if we make this method non abstract like (double calculate interest(){...} ) though it will be inherited by the subclass so, why we are making this method abstract whereas it will be done without abstract?
In this case, we would not be able to see the use of making it abstract. Let us assume you want the different body of the same (double) method in two different subclass objects of the superclass, then to make that we must have to make it abstract so that we could change it accordingly. For ex: abstract class a { abstract void m1(); } class b extends a { void m1(){ System.out.println("Hello");} } class c extends a { void m1() { System.out.println("Hii");} } class imp { public static void main(String[] args) { b o1=new b(); c o2=new c(); o1.m1(); o2.m1(); } }
@@pradhanipradhani4230 In this case, we would not be able to see the use of making it abstract. Let us assume you want the different body of the same (double) method in two different subclass objects of the superclass, then to make that we must have to make it abstract so that we could change it accordingly. For ex: abstract class a { abstract void m1(); } class b extends a { void m1(){ System.out.println("Hello");} } class c extends a { void m1() { System.out.println("Hii");} } class imp { public static void main(String[] args) { b o1=new b(); c o2=new c(); o1.m1(); o2.m1(); } }
@@sparshagrawal3506 class a { void m1(); } class b extends a { void m1(){ System.out.println("Hello");} } class c extends a { void m1() { System.out.println("Hii");} } class imp { public static void main(String[] args) { b o1=new b(); c o2=new c(); o1.m1(); o2.m1(); } } if i dont have abstract class will this code have no meaning
@@sparshagrawal3506 bhai jaisa ki sir ne video me btaya h ki agr hm abstract class ko inherit krte h and usme koi abstract method h to subclass ko bhi abstract krna pdega. And aapne aisa nhi kiya... M agree with your answer but not agree with sir's this lecture
I understand how to create the Abstract class and method, but why we need to create the abstract class and method. What is use, e can directly use the child class method no need of parent class.
Sir, if we have to override an abstract method in child class, then what is the need of an abstract method in the abstract class? We can simply inherit the abstract class and create the same method in child class. Then what is its use?? Please explain.
Hello Sir..Agar hmary pass 1 aisi class or aa jaye jo Saving account sy extends hui ho kya us k liye b zrori hai k wo Account class k abstract method ko define kry....KIndly tell me answer?
@@diverseduniya bro actually I have placed this time stamp here becoz whenever l'll have doubt on this topic then I'll directly jump here 😂😂😂 but thank u...stay safe 🤘🤘🤘
abstract class Animal { int legs = 0; abstract void makeSound(); } class Cat extends Animal { public void makeSound() { System.out.println("Meow"); } } public class Program { public static void main(String[] args) { Cat c = new Cat(); c.makeSound(); } } Ya code run hota hy koi error ni ata. Jb k cat class abstract ni hy. Kya abstract likhna zaruri hy??
EDIT: ignore the stars and underscores, I thought I could format this *explanation* to look good, but unfortunately UA-cam is broken! Mujhe suddenly *click* hua abstract classes kyun banate hein! To attempt polymorphism! Eg- Suppose bahut saare type ke shapes hein hamare pass, jinki hmne classes banai: * public class Triangle * , * public class Square * , * public class Rhombus* , etc. Meine in sabke andar _public int getArea()_ , _public int getPerimeter()_ functions banake rake hein. Now suppose I want to make a function that prints area and perimeter of a given object of any of these classes: * public void printAreaAndPerim(Triangle triangle)* *{* * System.out.println("Area: " + triangle.getArea() + " Perimeter: " + triangle.getPerimeter());* *}* ...but now I have to create this function for every Shape!!! Imagine so many overloaded functions! It will be a mess to manage. Even worse, agar mujhe kisi din aur shapes banani huin to mujhe fir se unke liye bhi ek naya overloaded function banana padega! Solution: Make a base abstract class. Mein in saari shapes ke liye ek base (abstract) class banaunga: *Shape* . Mujhe nahi pata har shape ka area aur perimeter ka formula, to me wo *Shape* ke derived classes ko implement karne ke liye chodh sakta hun. i.e: _abstract public class Shape _ _{_ _public int getArea();_ _public int getPerimeter();_ _}_ Ab, me har class ka definition change karke kar dunga: _public class extends Shape{_ .... _}_ ....Best part! Now I can just make the function definition to: _public void printAreaAndPerim( *Shape* shape) { System.out.println("Area: " + shape.getArea() + " Perimeter: " + shape.getPerimeter()); }_ And that's it!! All kinds of shape taken care of!
sir to fir hmlog abstractnmethod fir q bna rahe hai jab hmko extend class me method banana he pad raha hai to hm bina abstract ke method bna ke use to kar sakte hai na????
Lekin agar humne apni abstract class me koe abstract method declare kar dia jisme humne kuch return type aur parameter bhi set kar diye, to ye kese ty ho skta hy k is me kon kon sy parameters ayengy. aur wo kia kia information rakhengy. q k ye method to ham teacher k liye bhi use karengy aur student k liye bhi.. aur phir is tarha karengy to dono calss me ek jese hi parameters bnny parengy aur parameters to ham variable ko initialize karne aur us me values dalny k liye use karty hain. To abstract method ka faida kia hua???
Child class ko abstract nhi bnayenge qki hume object bnani hoti hai....But child class extend to karti hai super class ko...To... Abstract property to aayegi na child class me....👍 Ise bhi clear kigiye sr
why do we use abstract methods?.. anyway.. we are not doing any coding inside them! sir.. please explain with help of a sample case where abstract methods are useful.
you are a great teacher , your lectures are simply best ,keep up the good work sir , and please make more videos ,we support you fully ,i like very video of yours and i have already subscribed you
sir FYI 4.26 TIME pr ek error ye bhi to hai ki aapne example class ko public nahi liya jo ki nessesary hai ki main function wali class ko public kare ... BY THE WAY THANKYOU SO MUCH SIR FOR WHAT YOU DID TO US ... LIVELONG...
sir these videos are nice but i want jdk1.0 to jdk 1.8 key features,i mean what are the content it has ,coz it is being asked so many times in interview i wish you will read my comment & give me proper guidance
abstract class A { abstract void f1(); } class B extends A { void fi() { System.out.println("indian "); } } class abstract res { public static void main(String[] args) { B b = new B(); b.f1(); } } an error is gnret..in this error a msg print that B is not acstract and does not override abstract mathod f1() in A ..................pls help me sir..
your videos are better than even paid courses ,you really explain everything in a very deep and simple manner in simple language.U are amazing
sir you are great!!! aisa hmre teacher nhi padate!!thnku sir aapne hum garibo k lie yh video upload ki ...god bless uh sir
Ek dum sahi kaha aapne Naveen ji :)
I am 4yrs experience guy of Automation testing... But was very confused about abstract keyword... But after watching ur videos, I m very much clear ... Thanks for providing such contents.. it's helping for freshers as well experienced guy 🙏🙏🙏
by watching these video i am able to crack interview Thankyou sir
nice one sir, clear explanation, like it 👍
I understand how to create the Abstract class and method, but why we need to create the abstract class and method. What is use, e can directly use the child class method no need of parent class.
@@vinaypandey4752 , sir explained your querry in this video
Your videos are awesome👌we can get depth practical knowledge by it....Thank uu soo much sir☺
It is very good explaination. i understand my all doubts.
Awesome sir... My all doubts are clear..
Before watching your video it was like
Iron peanuts 🥜
wow !! wonderfull teaching !! i am seeing this playlist after 8 years
very clear explanation and concepts
i am fortunate to be part of your teaching through youtube ....god bless you sir
ap ko lecture dekh kar aisa mehsus hua java itna easy language hai aur hum dar kar bhaage
Its very helpful sir..thanks for this vedio..
Thank you sir, please describe abstraction with inheritance
superb
If any class contains at least one abstract method, it needs to declared as an abstract class.
That doesn't mean abstract class needs to have an abstract method.
Abstract class can have:
1. static variables and static methods.
2. instance member variables and methods.
3. Constructor which are called when a regular method inherits the abstract class and by constructor chaining parent constructor runs before child constructor runs.
4. final member variables and final regular method
But not final abstract method as making a method final means it can't be overridden and abstract means it should be overridden. So it becomes opposing.
Love with the video ❤️
Very well explained!
Awesome Sir
wooow sir good
thanq you so much sir
these videos are very helpfull for us
big respect for you...
Sir, what you taught was very clear but the real life example of why we are creating abstract method was not very clear.. Can you take another example and explain the need for abstract method.
Sir, Your videos are very helpful. I been following your videos for quite a lone time. Sir, in this tutorial and some previous one too, I did see when you're describing inheritance by a simple diagram, the arrow always comes from the parent to the child class. But Sir, are we not inheriting from the parent class? So the arrow must be from the child class to the parent class. Am I missing something ? Thank you For your effort though.
Thank you sir
sir app best ho
respect sir very useful
Sir Aapne jo bank accounts ka example diya hai usme account class abstract nahi liya hai lekin usme abstract method calculate ki banayi hai
Bhai sir forget that
Great sir .
Thank you sir, please describe Graphics Programming using AWT.
Thanks for making this series of beautiful videos sir.
Sir please explain object cloning in java
Thank you so much sir 🙏
Suppose ,maine abstract super class me kuch variable declare kiye aur unhe inherit karke ek sub class me lau to wo sub class abstract banani padegi to unako use karneke liye mujhe unko sub class me firse define karana padega to mujhe 2bar define karke kya faida.... Mujhe ye kehanahe sir ki 2bar define karne ke alava me ek bar kyo n variables ki define karu....
great ,sir 🙏🙏
thanks guru g
Mast
hello sir! thank you so much for making this kind of videos, these are very helpful. Sir I have a question regarding this lecture and that is, we are making abstract method in an account class that is abstract class but if we make this method non abstract like (double calculate interest(){...} ) though it will be inherited by the subclass so, why we are making this method abstract whereas it will be done without abstract?
Same question arise in me
In this case, we would not be able to see the use of making it abstract. Let us assume you want the different body of the same (double) method in two different subclass objects of the superclass, then to make that we must have to make it abstract so that we could change it accordingly.
For ex:
abstract class a
{
abstract void m1();
}
class b extends a
{
void m1(){
System.out.println("Hello");}
}
class c extends a
{
void m1()
{
System.out.println("Hii");}
}
class imp
{
public static void main(String[] args)
{
b o1=new b();
c o2=new c();
o1.m1();
o2.m1();
}
}
@@pradhanipradhani4230 In this case, we would not be able to see the use of making it abstract. Let us assume you want the different body of the same (double) method in two different subclass objects of the superclass, then to make that we must have to make it abstract so that we could change it accordingly.
For ex:
abstract class a
{
abstract void m1();
}
class b extends a
{
void m1(){
System.out.println("Hello");}
}
class c extends a
{
void m1()
{
System.out.println("Hii");}
}
class imp
{
public static void main(String[] args)
{
b o1=new b();
c o2=new c();
o1.m1();
o2.m1();
}
}
@@sparshagrawal3506 class a
{
void m1();
}
class b extends a
{
void m1(){
System.out.println("Hello");}
}
class c extends a
{
void m1()
{
System.out.println("Hii");}
}
class imp
{
public static void main(String[] args)
{
b o1=new b();
c o2=new c();
o1.m1();
o2.m1();
}
} if i dont have abstract class will this code have no meaning
@@sparshagrawal3506 bhai jaisa ki sir ne video me btaya h ki agr hm abstract class ko inherit krte h and usme koi abstract method h to subclass ko bhi abstract krna pdega.
And aapne aisa nhi kiya...
M agree with your answer but not agree with sir's this lecture
I understand how to create the Abstract class and method, but why we need to create the abstract class and method. What is use, e can directly use the child class method no need of parent class.
Sir, if we have to override an abstract method in child class, then what is the need of an abstract method in the abstract class? We can simply inherit the abstract class and create the same method in child class. Then what is its use?? Please explain.
Sir agar hum abstract method kilye overriding karen ge to per inherite karne ka kia piada ???
How can be create an incomplete class without using abstract keywords in java
Very Informative
sirg u r greate...please kbhi pune mai aeyee...
Hello Sir..Agar hmary pass 1 aisi class or aa jaye jo Saving account sy extends hui ho kya us k liye b zrori hai k wo Account class k abstract method ko define kry....KIndly tell me answer?
,🙏🙏🙏👏👏👏👏👏
can we declare static method as abstract?? Ex: abstract public static void getArea(int r); //correct or not??
sir, please ye topic bataye Graphics Programming using AWT.
7:42 why abstract method is used
to force subclasses to use that function
@@diverseduniya bro actually I have placed this time stamp here becoz whenever l'll have doubt on this topic then I'll directly jump here 😂😂😂
but thank u...stay safe 🤘🤘🤘
@@satyamraut333 great bro
abstract class Animal {
int legs = 0;
abstract void makeSound();
}
class Cat extends Animal {
public void makeSound() {
System.out.println("Meow");
}
}
public class Program {
public static void main(String[] args) {
Cat c = new Cat();
c.makeSound();
}
}
Ya code run hota hy koi error ni ata. Jb k cat class abstract ni hy. Kya abstract likhna zaruri hy??
Not necessary becoz make sound method we have override
sir sub class bnane Wala parant class k function ko apne according define krega Kya?
Very nice
EDIT: ignore the stars and underscores, I thought I could format this *explanation* to look good, but unfortunately UA-cam is broken!
Mujhe suddenly *click* hua abstract classes kyun banate hein!
To attempt polymorphism!
Eg- Suppose bahut saare type ke shapes hein hamare pass, jinki hmne classes banai:
* public class Triangle * ,
* public class Square * ,
* public class Rhombus* , etc.
Meine in sabke andar _public int getArea()_ ,
_public int getPerimeter()_ functions banake rake hein.
Now suppose I want to make a function that prints area and perimeter of a given object of any of these classes:
* public void printAreaAndPerim(Triangle triangle)*
*{*
* System.out.println("Area: " + triangle.getArea() + "
Perimeter: " + triangle.getPerimeter());*
*}*
...but now I have to create this function for every Shape!!! Imagine so many overloaded functions! It will be a mess to manage.
Even worse, agar mujhe kisi din aur shapes banani huin to mujhe fir se unke liye bhi ek naya overloaded function banana padega!
Solution: Make a base abstract class.
Mein in saari shapes ke liye ek base (abstract) class banaunga: *Shape* .
Mujhe nahi pata har shape ka area aur perimeter ka formula, to me wo *Shape* ke derived classes ko implement karne ke liye chodh sakta hun.
i.e:
_abstract public class Shape _
_{_
_public int getArea();_
_public int getPerimeter();_
_}_
Ab, me har class ka definition change karke kar dunga:
_public class extends Shape{_
....
_}_
....Best part! Now I can just make the function definition to:
_public void printAreaAndPerim( *Shape* shape)
{
System.out.println("Area: " + shape.getArea() + "
Perimeter: " + shape.getPerimeter());
}_
And that's it!! All kinds of shape taken care of!
if we can't create objects of abstract classes than why we need that??
sir to fir hmlog abstractnmethod fir q bna rahe hai jab hmko extend class me method banana he pad raha hai to hm bina abstract ke method bna ke use to kar sakte hai na????
ha lkn aagr abstract lga dega to forcefully hme overrriding krni hogi kuki agr abstract nhi lgnge to jaruri nhi h override krna lkn isme complsary h ......i hope apko smj aayi ho
Lekin agar humne apni abstract class me koe abstract method declare kar dia jisme humne kuch return type
aur parameter bhi set kar diye, to ye kese ty ho skta hy k is me kon kon sy parameters
ayengy. aur wo kia kia information rakhengy. q k ye method to ham teacher k liye
bhi use karengy aur student k liye bhi.. aur phir is tarha karengy to dono calss me ek jese hi parameters bnny parengy aur parameters to ham variable ko initialize
karne aur us me values dalny k liye use karty hain.
To abstract method ka faida kia hua???
sir ek java ka project class please diji ae then all student helps hoga
sir is it possible to lern JAVA without knowing C and C++
Yes we can . tumhe bus loops , conditions , variables k baare me padna hoga. best hoga python seekh lo. kum time lagega. accha bhi hoga.
sir plz use netbeans or eclipse
Extend class main bhi method likhan padta he to abstract quen banate
sir abstract class & method thora aur explain krye
When we are not using abstract method of supar class then why we are creating it ?
Fantastic....sir...have you made videos for android??
learn java first ....coz android dont have any scope now bcoz many android developers are there and i am also the one in bangalore
Really ?? NO Scope in Android??
Thanks sir ji
thankyou sir.
After overriding the abstract method on the child class, we can instantiate its object. Is that only the logic? Anybody please help
sir, could you please tell, why main class has been made abstract?
main class is not abstract clas , it is just named abstract
07:45 - 11:45
thnku sir
sir kia abstract class mei non abstract methods bi hoty hein??????
yesssss
Child class ko abstract nhi bnayenge qki hume object bnani hoti hai....But child class extend to karti hai super class ko...To... Abstract property to aayegi na child class me....👍
Ise bhi clear kigiye sr
Saiklum Mushahary ok sir...
Thank you...
@@Anjaliverma-he1el then we can simply have left abstract class only without creating methods. WHat is the point of creating methods then?
why do we use abstract methods?.. anyway.. we are not doing any coding inside them! sir.. please explain with help of a sample case where abstract methods are useful.
1) Force to make containing class abstract
2) force subclass to define abstract method
Can u please make a video on dependency Injection and Collision Principle
@@javabysaurabhshuklasir3459 these 2 will happen automatically ??
thank u sirrr... :-)
u r great sir
what is wrong in this code ?wow whoa what an explanation !!!!!!!!!!!!!!!!!!!!!!!!!!
Why make example class abstract??
Class is not Abstract its the name of class and alsi notice the keyword of any abstract class is
abstract class_name ;
Sir,will you please expound the use of abstract methods?
C++ nahi padhaa kyu nahi samajhte aap
Everything is fine just stop saying fuctions... Java have methods not functions.
Very helpful video. I was english medium student but still i feel great to learn in hindi.
Deepak Singh ..hehe bro
@@akashgupta-og1ph Akash Gupta ..hehe bro
Thank you so much ,sir
offline couching se java sikhna❌ java by saurabh sir ✅
you are a great teacher , your lectures are simply best ,keep up the good work sir , and please make more videos ,we support you fully ,i like very video of yours and i have already subscribed you
🙏🙏 my words can't describe how much ur video helped me ..u are unique sir
best explaination ever thanks sir
All applauses u well deserve sir 🔥
sir FYI 4.26 TIME pr ek error ye bhi to hai ki aapne example class ko public nahi liya jo ki nessesary hai ki
main function wali class ko public kare ...
BY THE WAY THANKYOU SO MUCH SIR FOR WHAT YOU DID TO US ...
LIVELONG...
Thanx Sir
Sirrr you are awesome , splendid, wonderful, god bless you
wonderful!
Thanks sir ji 🙏🙏🙏❤️❤️❤️❤️🙏🙏🙏🙏🙏❤️❤️❤️❤️❤️❤️🙏🙏🙏🙏🙏🙏🚩🚩❤️❤️❤️❤️🙏🙏🙏🙏🙏🙏🙏🙏❤️❤️❤️❤️
sir these videos are nice but i want jdk1.0 to jdk 1.8 key features,i mean what are the content it has ,coz it is being asked so many times in interview i wish you will read my comment & give me proper guidance
abstract class A
{
abstract void f1();
}
class B extends A
{
void fi()
{
System.out.println("indian ");
}
}
class abstract res
{
public static void main(String[] args)
{
B b = new B();
b.f1();
}
} an error is gnret..in this error a msg print that B is not acstract and does not override abstract mathod f1() in A ..................pls help me sir..
awesome video sir thankuu so much
Thanku sir....Or clear hua abhi....
much simplified!!! thamks sir!!
Sir You are really awesome.
Sir ,you are really great ! Thank you so much .
You're a great #Sir
Sir u r amazing. U teach very well
Best Explained Sir..
Best explanation 👍