This lecture offers a rigorous demystification of Java’s functional abstractions by bridging the gap between high-level syntax and low-level compiler mechanics. It is an essential deep dive for developers who value understanding the "why" behind the "how" in object-oriented design.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Core java Day 20 - march 10th batchAdded:
Even I was thinking the same. Actually, it is 20.
It's okay. We'll change that thing later.
Yeah, this is two times four is our 10 given. That is the reason.
This lecture number 20.
Okay.
>> [clears throat] >> So, guys, let's start with our today's lecture.
So, last class I'd given you introduction about why lambda's expression, what is functional programming, and what is the purpose of functional programming. We just covered the theory part of it.
That in functional programming we define what needs to be done, and how it happens to be implemented internally, we are not bothered about it.
Correct? It reduces the number of lines of code.
It comes with certain restriction.
If you're doing functional you know, programming, you're doing functional programming, you're using lambda's expressions for that, then this can be applied only on functional interfaces.
Okay?
Now, from here I'll continue further. So, let's just press control F and search for lambda's expression.
Okay.
So, now observe here.
In lambda's expression, we are now firstly going to take one example how this works and what exactly is happening here. Okay? So, I'm going to go here.
And the first step that we're going to perform is create one functional interface. Because without functional interface, your lambda's expression would not work.
So, I'm going to go here, and then create one interface.
Let's delete this all.
Right click.
Go to new. Create one interface called as A.
I will annotate this interface with at the rate functional interface.
Since it is functional interface, at any cost one method exactly has to be present.
Now, I'll right click, go to new, create a class A.
Class B.
And then what we will do now, we will implement we will implement this method in the class B. Now, can you tell me the steps to implement?
What are the regular steps we take? Can you tell me?
First step is you will write class B implements Okay, very good. Then?
Then you will override.
Correct? Then you will create an object of child class. Then you will call.
What if all of these things I do not do it, and still I implement this method?
This is where the concept of functional programming comes in picture. See, I'm just going to give reference variable of interface.
Can object of interface be created?
I've mentioned this earlier. Can I create object of interface?
No.
But can I create reference variable of interface?
I can create, right? So, now this reference variable, I'll just put equals.
And now you notice this interface A has a method.
Now, there is parenthesis around it.
Which means there are no arguments. So, I will just use the parenthesis.
If there was int x, I would write here int x.
Right now, it's a method without argument.
Then I'll use one hyphen, greater symbol, curly braces, terminate. That's it.
All that steps you said now will be taken care of internally. What all steps?
Implements, override, create object. This all is happening in one line.
Line number five.
What will happen now? Listen very carefully.
Now, when you are using lambda's expression, this line number five, this particular code.
Okay?
This particular code, let me put that here.
Now, what will happen here at this particular line is when the lambda's expression is used, right? What it will do now, it will firstly create one anonymous class.
What it will create?
Anonymous class. What is anonymous class?
A class that does not have any name.
A class without a name is called as an anonymous class.
Automatically one class is created.
Then what will happen? In that class, automatically public void test, a complete method is loaded.
Okay, step two. I'm not doing this.
This is all happening with functional programming now.
Because to access the test method, object has to be there. And to create an object, class has to be there.
Without a class, I cannot create object.
And without an object, I cannot access non-static member.
Do you all agree with this?
Please tell me.
Repeat what I said.
Yes, repeat what I said.
Huh?
And without class we cannot Very good. We cannot create object.
Correct? Very good. Now, observe.
The point here is right? In order to implement that method, I have to first override, complete the method, create an object, then call. But I'm not doing any of those things.
I just wrote this lambda's expression.
And upon writing this, what it is doing?
Automatically creating one anonymous class.
In that anonymous class, a complete method is being kept.
And now for that anonymous class, automatically one object is created.
What is created now?
For this class, object is created. And inside that object, what is loaded?
Non-static member is loaded. This non-static member is loaded inside that particular object. And then that object's address is stored in A1.
What is stored in A1?
Look, I did not do anything.
Everything is happening by itself.
Finally, object also created by itself, and address stored in A1. Now, I can write whatever content I want inside the method, like from test one.
And then, when you just use A1, it already has an object.
And when I now write test one, you see that it is able to call test one.
Where is implements? Where is overriding? Where is object creation?
I'm not doing it.
This is all happening with functional programming. Understand here now.
Functional programming defines you say what you want, and not how to do it step by step. Read this line once again.
Correct? Next.
What this does, it creates anonymous class behind the scene.
When you're using lambda's expression, what it did?
Created one anonymous class. Because they'll ask in interview, can you tell me how does lambda's expression work?
Right?
Questions, cross-questioning might happen like this in interview. Now, a class without any name is called as Now, why one anonymous class should be created? Because see, without a class, I cannot implement a method.
And without a class, I cannot create object. So, class is mandatory.
But this class has to be automatically generated now. So, lambda's expression is automatically generating anonymous class that doesn't have any name.
Then, the lambda's expression creates an object and loads the method by implementing inside.
So, what it does now, anonymous class is there, method is there, object created, that method now is loaded inside the object.
Then, object's reference to call that method is implemented.
Okay? So, three things is happening.
Anonymous class created, method is present, because a class cannot have incomplete method. Class will have complete method only. Now, that anonymous class object created, and that object address is given to A1.
Can you read this slowly?
Loudly.
Correct? So, from that anonymous class, it loads the method. Then, this one line, this all is happening behind the scene.
So, now is this definition correct?
You're just telling what you want.
And functional programming does this.
Now, this is very powerful thing when it comes to logic building.
When you learn stream API, it's all functional programming happening inside.
That's why the logic building can be done in one one line. That powerful it is going to be, which we will see later.
Okay? Now, example one has been completed.
Now, let's look at example number two.
Okay? Example number two.
What if I had one argument here?
Now, all you need to do is create A A1 is equal to this time, keep the argument inside it.
Lambda's expression minus greater curly braces, terminated with a semicolon.
Tell me, what are the three things it will do?
First, create a anonymous class. What is the second thing it will do?
Load the complete method in the anonymous class. Third thing?
Create an object of anonymous class, and non-static methods are now present inside the object. Next, object's address is automatically stored in A1.
Done.
Okay? Now, here, if I print X, you see A1.
Test one, 100.
Now, run. Observe here. What is it printing?
Very good. What is it printing?
100. Very good.
Everybody got this now?
Yes?
Now, there is one more thing you need to understand here.
And functional interface can have any number of complete methods.
I've already explained this earlier. Yes or no?
Any number of complete methods are allowed here.
Now, when an anonymous class is created for this interface A, now when an anonymous class is created for this interface A, it is not just incomplete method loaded, it is everything will be loaded into it.
Yes or no? Which means now that anonymous class object has how many methods?
Three methods.
Correct? Method one I'm already calling.
Let's call the method two.
See, because it's already implemented, there is nothing you need to do now.
Yes or no?
Correct? Is my number of lines of code reduced here?
Compared to the traditional way of implementing things, is the number of lines of code reduced here?
But this makes your code debugging difficult.
Right? So, whenever you're writing the code in the development environment, better for a proper debugging, you write the code logically line by line.
And when you move your code to production, wherever functional programming can be done, switch to that.
Because analyzing functional programming code, however, there are tools.
We have certain tools present in your debugging, which we can use to use it to analyze a Yes, functional interface stream API.
So, here there is a tool actually, which I'll which I'll show you later.
Right? When you go to debugging, there is a tool here. I'll show you that later.
Right?
So, there is a tool here, which we will see later.
So, this is called as trace current stream.
So, this feature was lately introduced for debugging the further concepts like stream API in Java, which I'll teach you later. We cannot learn that now. Okay?
Now, let's continue further.
So, is this program clear?
See, the variable names can be anything.
I purposely done that here, X and Y. The variable names can be anything here. But important point that you need to keep it in mind is this.
Oh-ho.
The important point that you need to keep it in mind is this.
That the type of argument and the number of arguments should match. Type of argument and number of arguments should match. Let's continue further.
Now, we have one very powerful feature called as stream API in Java 8, very popularly used by Okay, developers in the company. But we cannot learn that now. Why, sir?
Because to learn your stream API, we need to first complete collection, which is a data structures concept in Java, and functional programming. Functional programming, I just gave you an introduction now.
So, combined together, data structure and functional programming, we will do logic building. This is what our further plan will be.
Okay?
Now, the next thing, optional class also we cannot learn this.
Okay? Because to learn optional class, you should know exceptions concept in Java first.
What you should know first?
Exceptions concept you should know first.
So, marker interface already been informed by me what it is. That's done.
Everybody clear with this part now?
So, tell me, repeat all the features of Java 8. Which is the first one?
Default keyword. What is the second one?
Functional interface. What is the third one?
Lambda's expression. What is the fourth one?
Stream API. What is the fifth one?
Uh optional class.
All of these we will be using it in our projects. Definitely, we will be using these things in our project. But before that, we will also learn stream API later.
Now, let's proceed with our next concept, abstract class in Java. What we will understand now?
Abstract class in Java.
So, what is this abstract class?
See, abstract classes are special class in Java.
Okay, one minute. I'll just hold on one minute.
All right. Observe. Now, here, what is an abstract class? An abstract class is a special class.
An abstract class is a special class which can have both complete and incomplete methods in it.
Repeat this first line.
What is the first line?
The first line here is an abstract class can have both complete and incomplete methods in it.
Both complete and incomplete methods in it.
Fine?
Okay? So, let's try to build this now.
Let's try to build the complete and incomplete methods here.
So, firstly, I will build a complete method. See, public public void test one.
And this is a complete method. So, there is no problem.
Fine?
Now, you can also build an incomplete method. Public void test two.
But moment I create an incomplete method, you observe here, you observe here, what is happening is there is an error.
Because whenever any incomplete method is developed in an abstract class, firstly we have to add here abstract keyword, then only this becomes an abstract class, which I did not do it.
Now that I've added abstract keyword, it's an abstract class.
You can use this keyword before or after public.
That doesn't matter.
Before public or after public keyword, both it will work.
You can write here also.
Okay, no problem.
But in an abstract class, when you create an incomplete method, it gives an error. Reason being, the incomplete method that you have developed should have abstract keyword.
Without abstract keyword, incomplete methods are not allowed here.
Did you understand the first thing?
Read this definition.
Correct, can be present. Is this a complete method?
Is this an incomplete method?
If I remove abstract keyword, will it work?
No.
What is the rule here?
Add abstract keyword. I've added here now.
Now that we have added the abstract keyword here, now that we have added the abstract keyword here, understand the error is basically gone. The error is basically what? Gone. So let's now go back here. Observe now.
To define non-static incomplete method, it is mandatory to use abstract keyword.
We have done that.
The next thing is, in an abstract class, we can create both static and non-static members.
In an abstract class, we can create both static and So observe here, when I go to this abstract class, I can create public void test three.
Now, you can make this method static. You can make this method what?
Static. And there is no error.
Since static methods are allowed, main method is also allowed.
Okay? See, non-static is present, static is present. Likewise, even variables.
int x is equal to 100, non-static.
Static int y int y is equal to 500. Can you observe here?
Yes.
Now in this case, you observe now, both static and non-static members can be created.
Okay, so that is what the point here.
We are telling in an abstract class, we can create both static and non-static members. Read these three points loudly.
Once again.
We can create It was by mistake. I'm sorry, but what happened? I don't know what.
Okay. I think people mute all. Some participants are Okay.
Fine.
Okay. Everyone, anyway, there was no disturbance in the audio, right, online people?
I did not see the message. Meanwhile, read these three lines once again. I did not hear you people reading this. Uh read that.
Okay.
Now, understand at any case, creating incomplete static methods are not allowed.
You know very well. If I make anything incomplete static method, inheritance is not allowed. Hence, I will never be able to override that.
So what is allowed is only complete static method. Incomplete static methods are not allowed even in an abstract class. Is this point clear?
Everyone got this?
Yes.
Yes.
Okay. Now let's proceed further.
So my question is now, can we create an object of abstract class?
Carefully think about it and tell me.
Huh?
No. Why we cannot create?
There's no There is no logic in abstract method.
Correct. Object cannot be created here because incomplete methods cannot be loaded basically inside your object. An object can have only complete methods.
An object cannot have incomplete methods in it.
An object cannot have incomplete methods. The moment you see anything having incomplete method, object creation rule is gone. You cannot create an object. Interface cannot create object, incomplete method.
Abstract class cannot create object, incomplete. Then sir, this non-static and incomplete method, how to access?
Inheritance.
To a class, override and access that.
Which you will see in our further example. But now, can you please read this?
Okay.
Make sense? Because that is static.
Okay, next one.
We cannot create Okay, next.
Okay. Now let's see this one by one.
Okay?
We will firstly try creating an object.
There is an error.
Can you see that?
I'll comment this out now.
Now the next thing what I'll do is, I'll write some code in it.
Next, observe.
Observe.
Right?
Observe. Now Correct? Because it is static, I can access with a class name.
Object creation not allowed.
Now let's do inheritance and access.
I'll remove all static.
Okay? Can we do inheritance now? So let's create another class. Did you understand this example?
What I did now?
Since main method was there, since main method was there, I could run an abstract class directly. Now, coming to this part. Observe.
How do I do inheritance?
What are you inheriting from A?
One is the complete method, another one is incomplete method. Can I inherit incomplete method?
Yes, but then you have to override it.
Control one.
Add unimplemented method.
And here, I'm going to now write two.
You see how I'm accessing it now?
B B1 is equal to Now I can access all the non-static number.
B1.x.
It's a default variable. Packages are same. Need not make it public.
B1. Test one, complete method. B1.
Method after overriding I'm accessing.
Yeah? Run this and see.
Observe the code once.
Everybody got these points?
Okay. So now once again, I want students I want students to read all the points.
Understand and read, okay?
Make sense?
Okay. Can you see the first program?
Reason for error?
Why there is an error here?
Incomplete static method. Why there is an error here?
Object creation. Now see, error because multiple inheritance cannot be done.
What kind of class is this?
Abstract. What kind of class is this?
Abstract. Now what am I doing here?
Multiple inheritance. So for multiple inheritance, what is the thing here?
What is the thing here for multiple inheritance?
Abstract classes multiple inheritance is not allowed. Keep that in mind. Okay?
Now this is a very typical interview topic.
Difference between interface and abstract class.
A very commonly asked interview question. What is the difference between interface and an abstract class? So, see the difference. What is the first one?
Correct?
Interface supports multiple inheritance, but abstract class cannot. The first major difference. Second one?
Correct? We have already discussed about these points.
These couple of points just specify there and done.
Okay.
What kind of variable is this?
What kind of method is this?
Correct? I can create a main method and run abstract class.
Next.
Can you see here? Now, what kind of class is this?
Abstract. I'm inheriting to B. Is B an abstract class?
No. But, creating object of B, I can access members of A. Am I doing that?
Yes. Able to understand the programs?
Very good. Next.
Can you see here? Interface A.
Now, let's take this example here.
So, what I'll do is now, I'll create here I'll create here an interface A.
Okay?
And here, I will do one thing now. I'll make this class as an abstract class.
Okay?
Fine?
Now, here we will build one method.
Public public void test one.
Now, this is incomplete method.
I'm going to inherit incomplete method to abstract class by using the keyword implements.
And you see there is no error.
Why there is no error?
Because incomplete method can remain incomplete in abstract class.
Abstract class supports incomplete method.
If I remove this, there is an error.
But, since the class is abstract, the interface incomplete method that you inherited can remain incomplete in an abstract class. Did you understand this point?
Everyone?
Yes?
Sure?
Okay. So, come back here.
Can you see that now? What are we doing?
Interface A.
Abstract. I'm creating another method in it now.
I'm creating another method in it. So, how many methods are present in B now?
Two methods. What are the two method names?
Test one and Now, I'll create one normal class called as C.
I'll create a normal class called as C.
Observe.
Now, this class C.
This class C.
I will type here extends because it's a class. So, extends keyword should be used.
Why there is an error?
What are you inheriting from B?
Two incomplete methods. So, press control one.
Add unimplemented method.
And here, s y s o type here from test one.
Correct?
Same way, copy.
Paste this here from test two.
Type here main method. C C1 is equal to new C. Let's write C1 dot test one. C1 dot test two. Run this. Observe.
Did you understand the program what I did here?
Online students, are you all able to follow?
So, I think some student in your batch is giving us the topic names.
Right? So, today's class also topic name you please give it to staff because when we are adding that up in the new software, I want to give the topic names and upload the videos there. It'll become easy for you to revise the topics later.
Okay? So, today's topic has to be lambdas expression.
Okay?
Abstract class.
Lambdas expression and abstract class. Okay?
Because there'll be huge content.
So, obviously now we're just learning Java, but there'll be huge number of videos. Near about 250 300 videos will be there.
So, you know, topic names is what just help whoever is doing it.
Okay? Now, the next thing Understand.
Since Java 8, complete static methods were allowed in an interface. So, this was not the case earlier, but now, you can see here that if it is an interface, inside interface, static incomplete method is not allowed.
But, moment you make it complete, you see the error is gone.
I can now here write down from test one.
And then, a main method. A dot A dot test one.
Variables anyways by default are static and final. Since final, initialize it.
And now, you will print here capital A dot X. Run this and see.
Yes or no?
Everybody, did you understand this now?
Everyone clear with this?
So, this is allowed in interface. Can you read this point again?
Okay?
Now, the next important topic starting tomorrow, we will start with exceptions concept starting from tomorrow. It's a very big lengthy concept.
Very simple, Muhammad. In an interface, complete static methods are allowed.
That's it.
It's a simple thing.
This is your interface.
Complete static methods are allowed. And I'm able to run the interface itself.
You see?
It's not a class.
I'm running the interface only.
So, complete static methods are allowed.
What is not allowed?
What is not allowed?
Incomplete. See, moment I make it incomplete, error. Did you understand that, Muhammad?
Clear with this?
Any other doubts?
I'll also give you an option later to unmute and ask my question in online class.
I'll say shuru hoga pehle naming kare.
And you'll also have the option to unmute and talk to me.
Okay, during the live class.
Okay? That option we will find that out.
Okay?
So, that will be more easy for you to create a two-way interaction, which will be as good as you sitting in front of me and listening to the lecture.
Okay? So, that feature will be added up.
Unmute and speak during the class.
No, no, no, no. Sanjay, I will just tell you. No, it will not be like this. Everybody on mute only.
So, you are all Everybody will be on mute only. Only when you want to talk to me, you will unmute.
That's it. Otherwise, everybody will put themselves on mute. That is a class rule, which everybody will obey. Why student will purposefully disturb someone's class?
Provided he's a student.
All right.
Yeah, you can do that also. You can also, you know, ask us a question. That will all be there. Don't worry.
Okay.
Enough for today?
Uh doubt session be there again.
Okay? When lot of students are asking for the doubt session, a special doubt session will be organized.
And they won't be getting that again.
We'll not disturb our weekday classes for that. Probably Saturday.
But, some odd timing we can keep it so that people will be May be a lot of time later just at 8:30 or yeah. Sorry, 8:30 just over here is the things like that.
Huh?
Yeah?
Yeah, yeah, yeah?
They go yeah.
Up lening about it some Up okay seek and I bus. That is important thing.
Koi be cheesy AC implement and they get jagged.
Because, you know, we can understand very well our students.
Okay?
Yeah, I guess I will but see we will have more opportunities for adding more courses.
So, that's the whole thing. Your learning can become more extreme.
Okay? So, these all things will be there and I'll be offline also. I'm not telling that I'll be only online.
I'll also come offline. I'll also take online.
Whenever required, I'll be offline also.
It's not that this will happen but learning mechanism will be in fact more excellent.
Tomorrow's class I'm coming here since the complete setup is not done yet.
Let the setup everything happen.
After that only I'll take a call. Let me do a proper setup.
May may may do a series of recorded class.
September batch come over my online download.
People can access with my live class by the way whoever wants to learn fast man.
Okay?
Second thing what we will do is our live classes will keep happening. Who's interested know I will sit in live class daily that seriousness will be there because the timing is fixed.
Everyday I know that at this time I have to attend my live class. That seriousness will be there.
Who wants to go with that? They'll go with that approach.
Third thing as I talked about the angular one I will start my recordings and keep putting it into it.
So, whoever basically does that as what we're talking about it want to unlock the angular classes they can go with that concept.
Got it?
Angular DevOps complete deployment agent TK. This is the future courses which I have already thought about.
Okay? Is this clear everyone?
This is the whole plan.
In class there will be mentor support.
There's only one mentor here.
So, nobody will be able to give you support what I'm teaching you all because that's my content.
Yeah?
So, but
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











