Java 8 Predicate, Function, Chaining, Predicate Joining interview questions (Live Demo) Code Decode
HTML-код
- Опубликовано: 4 окт 2024
- In this video of code decode we have covered Java 8 || Predicate || Function || Chaining || Predicate Joining interview questions (Live Demo)
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
here are lots of new features which were added in Java 8. Here is the list of important features which are mostly asked as java 8 interview questions:
Lambda Expression
Stream API
Default methods in the interface
Predicate
Functional Interface
Optional
Method references
Date API
Nashorn, JavaScript Engine
Main advantages of using Java 8?
More compact code
Less boiler plate code
More readable and reusable code
More testable code
Parallel operations
Q) What are predicates?
Predicate is a predefined Functional Interface (Having only 1 abstract method).
The only abstract method of predicate is test(T t):
public boolean test(T t);
Whenever we want to check some boolean condition then you can go for Predicates.
Q) How to use Predicates?
Say if you need to test if the length of the given string is greater than or equal to 5. Then in such situations where you need to test conditions, use test() method of predicate.
Q) Type parameter and return types of Predicates?
Input to predicate can be anything like
Hence only 1 type argument is required which is input type in predicate.
Return type is not required as its always Boolean only.
Q) Advantages of Predicates?
Code Reusability
If you have same conditions being used 100 times in a prgram then you can write once and just use 100 times with checkLength.test(different string to be tested).
Conditional checks are holded by Functional interfaces.
Q) What is Predicate joining?
You can combine predicates in serial predicate
Three ways to join :
And
Or
Negate
Eg if you want to test 2 conditions:
To check length of string
To check if length is even.
Q) What are Functions
Function is also a predefined Functional Interface (Having only 1 abstract method).
The only abstract method of Function is apply(T t);
R apply(T t);
Given some input perform some operation on input and then produce / return result (not necessary a boolean value).
This takes 1 input and returns one output.
In predicate we used to take 1 input and return type is always boolean.
In function return type is not fixed hence we declare both input type and return type.
Q) What is Functional chaining
We can combine / chain multiple functions together with andThen .
There are two ways to combine functions:
f1.andThen(f2).apply(Input); - first f1 then f2
f1.compose(f2).apply(Input) - first f2 then f1
Multiple functions can be chained together like :
f1.andThen(f2).andThen(f3).andThen(f4).apply(Inputs);
-------------------------------------------------------------------------------------------------------------------------------------
Code Decode Playlists
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
GIT : • GIT
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
Linkedin : / codedecodeyoutube
Instagram : / codedecode25
--------------------------------------------------------------------------------------------------------------------------------------
#java8InterviewQuestions #java8newfeatures #java8
I have saved each of your playlist, I keep on playing them all day. Thankyou for such amazing contribution, can't wait to support this channel monetarily .
Thanks Gyan. Means a lot to us. Great to have you with us. 🙂🙂👍👍
Guys this is my first comment in RUclips and I must say this channel is awesome. I am working in a IT company and these videos are real gold. Thank you so much and please bring more of this content 😊👌
Thanks Prajjval. We are glad to have you as code decode family. Thanks for the motivation 👍👍🙏🙏
Earlier when i tried to learn predicate and functions it looks very complicated to me, but after watching your tutorial it looks to be simple thing. Your way of explaining it awesome.
Thanks Shubhi. We are glad u understood the core concept 🙂🙂. Keep learning keep Growing Shubhi 👍👍
Like your excitement and passion that you explain. You teach the concepts with simple, easy to understand examples. God bless you Mam !
Thanks Kusuma. Thanks for writing back to us. Much Appreciated.
I am going through all your java 8 videos since today morning . Your explanation is really clear with code so that even the difficult topic seems easy. Great job . Thanks 🙏
Thanks a tonn Priya. Keep learning keep Shining Girl ⭐✨⭐✨
This channel provides a better Explanation than courses available on PluralSight. Thanks for video
Hehe . Thanks for such a unique and awesome compliment Sumeet. Means a lot to us 🙂🙂👏👏
Best channel till date...last time you helped me in my selection around 2 years back..
and now i am here again for the prep of next journey...
You will rock Sahil . Keep learning keep shining Man 🎉🎉 all the very best 👍👍👍👍
Thanks for sharing the Java 8 features and the way explained concepts are really understandable.
Thanks Omsri 👍🙂
Hi code decode it's so nice to see all videos at one place with clear explanation while preparing for interview, can you please share the PPT which you are explaining in this series.
Hi @Code Decode, thank you so much for the effort for these content.. It would have been great if could share these slides with us.
Thank you so much for your patience and for explaining each and every minute detail very clearly.
Thanks for motivation Suresh🙏.
Thank you for such clear explanation of these java 8 features along with easy to understand examples.
Very interested to see the video. Please upload more video for our technical knowledge meanwhile I will inform my all friend to suggest who need technical knowledge
Thanks John 👍
Very good explanation best channel to preparing for interview . Thank you
Thanks 👍
What a crystal clear explanation!! Thanks a lot for sharing knowledge 👏
🙏🙏👍👍
Helps to understand easily and expecting a video on other functional interfaces soon
Thanks
Will upload soon 👍
Appreciate your Great efforts in providing very useful topics. looking forward to seeing other topics as well like collections, threads,spring and rest
Thanks for the kind words.
Please check out collection and spring video on our channel. It is already there.
much appreciated for the explanation madam, you deserve my subscription of this channel
Thanks Srihari 🙂👍
please do video on consumer chaining ..........
.u r helping a lot.... madam g ...
u r great for that much of patience
and
hats off to u for knowledge
ruclips.net/p/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
Hi mam, i have suggested your series to many of my friends, awesome work 🙏
Thanks for supporting us Manogna 🙂👍
Very useful video to understand about predicate and function 👍
Really thanks a lot, for saving our time. If i have doubt with your concepts , i googled it. So then my conflicts of idea goes off. I see the realiability of content you are making. ❤
Thanks a lot Priyanka ❤️❤️ means a lot to us
I generally ignore 'like subscribe and comment' thing but I can't help liking the content and the way you explain/express, thankyou very much. 'COOOL' 😍 this the thought I get at the end of your videos.
Happy to support you in petron,if you have an account.
Thanks a lot 🙂🙂
Hi Mam,
All videos are so clear and very well explained... thank you ! But my only suggestion is please keep your phone in silent mode not vibration mode.. vibrations in the middle of video really annoying.
Yes Shruthi. We understand. Actually we just shoot, may be in multiple takes. Single shot video is not practically possible bcz after 15 minutes of continues speaking, we need gulp of water or sometimes sneeze or something disrupts the video. So many a times we miss to silent the phone and shoot back. That's why sometimes this happens. Sorry for the disturbance. Thanks for letting us know and bringing this issue to our notice 🙏
Thanks for the nice Explanation!!! Please upload Streams concept as early as possible.
It's already upload. 😊
It's in same playlist. Please let me know you don't find it.
All your videos are really helpful to understand and remember the Java concepts & to prepare for the interviews. Please do Part 4 of this & a video on Spring Boot Microservices concepts🙏
Thanks 👍. Part 4 is almost ready. Will upload that soon
Content of ur vedios are very good and with a very good explanation as well,,,keep going with good work
Thanks poonam for the nice words
Your explanation is really superb. Ton of thanks whole heartedly 🥳🤝💐
Thanks for the nice words
Perfect content.. Please upload on further topics.
Sure will upload them soon 👍
Great Explanation. Keep continuing these kind of videos. I request you to do video's on java design patterns.
ruclips.net/p/PLyHJZXNdCXselvpjEhygQ9GlDQihtQj6i
Thanks mam....
Your explanation made the topics very easy to understand.
Thanks Sanjay 👍👍
Than you so much. Your videos are very helpful to remember easily. with in short time you are giving more content, I am very interesting to watch this videos. Kindly made videos for the remaining topics in java 8.
it's almost ready. will upload very soon 👍
Please do a video on consumer and supplier with more examples and a video on parallel processing of streams will also be helpful. Thank you
Will upload this soon. It's almost complete.
@@CodeDecode thanks
👍
Good knowledge pls upload further videos. Really thanks a lot
Sure will upload soon 👍
Please upload react n angular questions also... Thank u so much.. Ur way of teaching is incredible... Keep up...
Sure. Will upload them soon 👍👍
Best video that I've come across for Predicate, Function, Consumer, Supplier, BiXXX.
Before this never really understood the concept
Thanks Abhishek 👍👍
you are amazing mam....plz keep flowing such knowledge with us..
Thanks a lot Pranay🙂👍
Please keep up the good work.
You are an excellent teacher.
Thanks 🙏🙏👍
Clear explanation with example. way to go
Thanks 🙂🙂👍👍
this is very amazing channel, please continue your good work mam❤
Sure Lokesh you will see more videos on channel 😀
Very helpful videos. Thanks
Thanks..
At 1:53 testStringLength(String s) can/should be replaced with just one return statement as follows:
boolean testStringLength(String s) {
return s.length() >= 5;
}
Great effort Mam
Thanks Joseph 🙂👍
Hi, You are awesome while describing any thing with code, I am following this channel since long, Do we have a repos for this or all the videos you have?
🙂 sure will search 🙂🙂
Watched Pluralsight and other good youtuber videos on java 8 but never explained as clearly as you, I used to tell in interview that i donot know java 8
Thanks Rahul🙂
Thanks for the amazing content, we love you!!
Thanks Akarsh😇🙏👍👍
Amazing explanation
Thanks
your videos are just too good. thank you
You’re welcome
Your playlist is life saving mam, Thanks for your details explanation can i get that ppt from which you are teaching it will be huge help thanks
The best explanations... keep posting it
Thanks.....
Nice contents usual :) but still, we need a lot of interview questions related to Java 8.
Thank you so much :)
You will get next video very soon it's almost ready.
@@CodeDecode Waiting
@Code Decode... Please create a video explaining Java Generics taking some examples of method suggestions that pop up on IDEs, and how to understand there requirements from Generics perspective.
for e.g.
obj. {suggestion list : " forEach(Consumer
really each and every video is full of information and delievered very simple way and could you please upload all souce code for more clarity for the user, all the very best ...keep doing this..thank you
can you please make a tutorial video on this in built functional interfaces topics as well as streams
Very Useful..thanks..
you're welcome
Awesome 👍
Thanks a ton vetri 🙂👍
thank you very much, it saved me a lot of ime
you're welcome
I have cracked many interviews under your guidance, Can you plan a book or PDF document for Java interviews, It will be really useful...Thank you for sharing your knowledge.
Thanks for the awesome videos with nice explanation. You would have put lot of effort..👍
Thanks for the motivation Sudhakar 👍👍
Thank you so much for providing such a great content.
👍👍
Yes please create playlist for understanding
Hello mam,
Please start web services and spring framework interview questions.
Sure. We do have spring boot playlist. please do check that too. 👍
Very nice....
Thanks Abirami👍🙂
Hi Code Decode , Can you please make java series on predicting output type interview questions? It will be very very helpful in real time interviews.
Have you explained Generics in any video? Could you please upload if not present? Thanks a ton for all the videos. You are a lifesaver for java interview questions.
Sure we will create one Priyanka🙂👍. Thanks
grate one
Thanks Tushaar 🙂🙂
Nice
Thanks and All the best for the interviews
Very useful and crystal clear explanation.Thank you very much for your videos.
Can you please explain about the chaining in BiXXX functional interfaces if it's possible in java?
Very good lecture
Thanks 👍
Please upload seperate video on remaining topics also of consumer, supplier and Bi****
It's almost ready, will upload that soon 👍👍
very clear explanation
Thanks ....
please provide PPT and demos used so that we can brush up quickly before going to interview. Thanks!!
One more request, can you please add video on Spring Integration
Sure Shubhi, once done with microservices playlist, we will move to this👍👍
Hi Mam,
How the combo will work if we have such code snippet below how to guess what will happen first and how it will process:
doubleIt.andThen(cubeIt).compose(doubleIt).andThen(cubeIt).compose(doubleIt).apply(2)
Very clear and simple explanation thanks a lot. Where & how can we download materials or code samples
Hi. It's very much clearer. Thanks a lot! 1 question. May I know andThen vs compose? Logically both are same right. We can achieve compose by changing the function order. May I know the differences??
You are making everything is simple and clear. Could you please explain about Wrapper classes. Even though it's simple I'm struggling to explain when interviewer asks. Also please explain about Spring MVC.
Yes Preethi, they are logically same 🙂👍. Sure we will cover wrappers and MVC 👍
@@CodeDecode Wow Thank you! I'm waiting.
@@Preethipree1 👍🙂
Excellent video! Thank You.
On 9:28 please can you show the example of how to do code reusablity, as what I understand is we can not pass arguments in Method Reference way, so how can we reuse code when we can not pass argument in this case ?
You explained it very well... Could you please share Angular knowledge also if possible?
ruclips.net/p/PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i
Here is what you need Pankaj 👍
@@CodeDecode Thankyou :)
One thing if function can do the functionality of predicate means it can return boolean value then why Java 8 has introduced predicate
In real time coding in real projects, there are more of conditional checks . To handle those, you are given a flexibility that you don't have to define a return type, just use predicate.
Do u have any classes or course as well. I never commented before on RUclips. Your videos are amazing
Hey Astha Thanks for commenting. 👍No Astha We don't have any paid courses or classes, everything is on RUclips completely free. What do u need specifically?
@@CodeDecode Could you please cover Java Streams - Collectors, Stream Builder, Stream support and Short circuit Operators.
And
Optional API please
Nice Topics Astha. We will target these topics on priority now.
@@CodeDecode thank you so much. I have shared your RUclips channel link to all my friends
Thanks for sharing!. Can u also upload more parts with the remaining concepts of J8
Next video is almost ready it is scheduled for Tuesday morning. Stay tuned for it.
Really useful helps in quick learning of the concepts in detail. Thank you, can you
Please make video of design patterns with real time examples.Also can please make videos on JDK 1.11
ruclips.net/p/PLyHJZXNdCXselvpjEhygQ9GlDQihtQj6i
Thanks Krishna 👍👍
@@CodeDecode Thank you and looking out for JDk1.11 features please..
Sure, wr will create seperate video on that👍👍
Code reusability can also be achieved using recursion then why do we need to use Lambada or predicate?
Recursion is the technique of making a function call itself. Predicate is used to test boolean condition in code. You can't mix different business logics.
thanks for this topic
👍
Good explanation Mam
Thanks
I have a question. You explained that defining predicate in one class and then we can re use it where ever we want it. But for that the predicate must be defined at class level like member variable of a class. Is it correct?
Next question is if we do that , is it really object oriented,because can lamda expression be defined as a state of an object ?
Thank you
Hey Pankaj, yes you can create it class level. And yes lamba as already told in previous videos, Lambda is a way to introduce Functional programming in Java. It's not an object oriented concept anyways. 👍👍
Thank you . Understood 👍
👍👍Anytime Pankaj 👍👍
Thanku so much
you're welcome
Hello,thanks for all these videos.
Do you already work in IT?
Yes Manoj, we all are working IT professionals working with mncs with work experience ranging from 6 to 10 years
@@CodeDecode Thanks again....
Very well explained !
Thanks
Another awsome video. Can you please cover microservices with new spring cloud version avoiding any depricated dependencies . Like explain spring cloud gateway instead of zuul and resilience4J instead of hystrix etc.
Really helpful. Where i can find these docs shown in video?
Every thing we covered is in the description below Jashandeep 🙂👍. Anything u need??
@@CodeDecode yeah. I already saw it. But it would be great if we can download docs or ppt shown in your videos. Btw your content is really helpful for interview preparation in short time.🙂
Actually we do have messed up docs with blogs urls and sites and many more things which can cause copy right issues for us that's why we don't share it. U need anything specific, we can create a word doc for that topic and share it with u
Really Helpful
Thanks mahesh
Awesome ...please make consumer and supplier concept also
It's already available on the playlist👍👍
@@CodeDecode yaa part 4 saw it after posted
@@CodeDecode and also i started ur videos since saturday and finished all except garbage collection .. please upload more and more videos
Please do Consumer and Supply as well madam.
ruclips.net/video/7-ALyd6OAaQ/видео.html
Can you please share any ppt with code snippets.it will be very useful to revise
hi . can you please create video on collections with the same way which you created for java 8 features like wise concept with example pointing to interview questions . thanks
We already have a video on that :
ruclips.net/video/KfoNYoVUBJI/видео.html
great videos!!
Thanks
While explaining in eclipse please remove unwanted code, we are confusing
Ok
Could you please provide the presentation link so that it will be very helpful to all of us ...
thanks for the content. but it would be great if you could share the github link for the code