#64 Abstract and Anonymous Inner Class
Вставка
- Опубліковано 17 жов 2024
- Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-sp...
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
Java For Programmers:- bit.ly/javaPro...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
In this lecture we will learn:
Abstract and anonymous inner class
Use of anonymous class with an abstract class
Example of abstract and anonymous inner class.
#1
When you want to use an interface and an abstract class only once, then you can simply use an anonymous innner class in place of that.
You can also provide the implementation for multiple methods in an anonymous inner class.
Anonymous inner class can implement only one interface at s time.
Anonymous inner class can either extend a class or implement an interface at a time.
We can create object for abstract class by providing the implementation of an abstract method in an anonymous inner class.
e.g.,
abstract class A
{
public abstract void show();
}
In main methid:
A obj=new A()
{
public void shoe()
{
statement;
}
};
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com
If I understand correctly, by creating an anonymouse inner class, we are doing implicit upcasting a well to the parent class whose object is being created. So any new methods etc that we define in the anon inner class wont be available. So the use case of anon inner classes is just for method overrides?
Great series so far @Telusko!
You are teaching skill 👍
watching from Kenya.
I did it in abstract lesson without knowing inner class!!
what is an application for this?
Attending Interview
To create single object from an interface or a subclass without defining the subclass(cause we only need one object).
class or interface Expected erorr
damnnnn greattt !!!!