Java 8 Predicate, Function, Chaining, Predicate Joining interview questions (Live Demo) Code Decode
ฝัง
- เผยแพร่เมื่อ 3 ต.ค. 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 TH-cam 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 👍👍🙏🙏
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 ⭐✨⭐✨
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 👍👍👍👍
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.
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 👍
Hi mam, i have suggested your series to many of my friends, awesome work 🙏
Thanks for supporting us Manogna 🙂👍
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
Very useful video to understand about predicate and function 👍
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.
th-cam.com/play/PLyHJZXNdCXselvpjEhygQ9GlDQihtQj6i.html
Good knowledge pls upload further videos. Really thanks a lot
Sure will upload soon 👍
Please keep up the good work.
You are an excellent teacher.
Thanks 🙏🙏👍
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.
Thank you so much for providing such a great content.
👍👍
Very helpful videos. Thanks
Thanks..
Thanks for the awesome videos with nice explanation. You would have put lot of effort..👍
Thanks for the motivation Sudhakar 👍👍
@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
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 👍🙂
Awesome 👍
Thanks a ton vetri 🙂👍
can you please make a tutorial video on this in built functional interfaces topics as well as streams
Very good lecture
Thanks 👍
Good explanation Mam
Thanks
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.
Please upload seperate video on remaining topics also of consumer, supplier and Bi****
It's almost ready, will upload that soon 👍👍
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)
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
th-cam.com/play/PLyHJZXNdCXselvpjEhygQ9GlDQihtQj6i.html
Thanks Krishna 👍👍
@@CodeDecode Thank you and looking out for JDk1.11 features please..
Sure, wr will create seperate video on that👍👍
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.
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 👍👍
Thanku so much
you're welcome
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.
Please do Consumer and Supply as well madam.
th-cam.com/video/7-ALyd6OAaQ/w-d-xo.html
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.
Could you please provide the presentation link so that it will be very helpful to all of us ...
could u pls gave an example for predicate with custom class instead of string
Thanks for sharing the Java 8 features and the way explained concepts are really understandable.
Thanks Omsri 👍🙂
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 :
th-cam.com/video/KfoNYoVUBJI/w-d-xo.html
Please release videos on stream api and other java 8 features
Sure 👍
Do you have the pdf for your explanation. Your explanation is awesome.
Hello mam,
Please start web services and spring framework interview questions.
Sure. We do have spring boot playlist. please do check that too. 👍
where can we get the ppt which you have created. can you share it with us, if possible ?
Every thing is in description box below Kiran. what else can we help you with?
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 🙂🙂👏👏
Thank you for such clear explanation of these java 8 features along with easy to understand examples.
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.
Thank you so much for your patience and for explaining each and every minute detail very clearly.
Thanks for motivation Suresh🙏.
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🙂
Very good explanation best channel to preparing for interview . Thank you
Thanks 👍
Helps to understand easily and expecting a video on other functional interfaces soon
Thanks
Will upload soon 👍
Thanks for the amazing content, we love you!!
Thanks Akarsh😇🙏👍👍
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;
}
please do more and more tutorials madam
sure jagdish we will create more
While explaining in eclipse please remove unwanted code, we are confusing
Ok
What a crystal clear explanation!! Thanks a lot for sharing knowledge 👏
🙏🙏👍👍
One more request, can you please add video on Spring Integration
Sure Shubhi, once done with microservices playlist, we will move to this👍👍
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.
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 🙏
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
👍
can you please upload the remaining topics also
th-cam.com/play/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy.html
Really nice, tq for sharing awesome knowledge...and can you please share code and relevant information data..
Will upload this on git and will give you the link to clone soon 👍
@@CodeDecode ok tq..
Plz share link......
Hi, Below is the git link. Please let me know if you are able to clone and get the code base for reference.
git@github.com:codedecode25/Java-8-demos.git
or
github.com/codedecode25/Java-8-demos.git
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
th-cam.com/play/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy.html
When will you publish consumer, supplier, stream and parallel stream video ? I have interview scheduled very soon. Need your videos to crack it
Hi Sajal. Content is almost ready. Video upload is scheduled for Tuesday morning. All the very best for your interviews👍👍. Hope you reach your dream job soon. We are eager to listen from you once you land at your dream job.
can anyone please explain this Write a Java program to display those starting with A and having length of 3 characters in java8. given string array. i tried to use filter and store it in two different list based on different condition, then was function chaining required? I was not able to complete this
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
Please upload react n angular questions also... Thank u so much.. Ur way of teaching is incredible... Keep up...
Sure. Will upload them soon 👍👍
thank you very much, it saved me a lot of ime
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....
Hi, Thank you for such informative videos. Can you please tell us from where we can get this ppt's which you have prepared. Thanks in advance.
Hi Jayesh, it's just a random points that I add to ppt for my reference so that I don't forget what I need to teach in that session . It's just rough points.
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
much appreciated for the explanation madam, you deserve my subscription of this channel
Thanks Srihari 🙂👍
Your explanation is really superb. Ton of thanks whole heartedly 🥳🤝💐
Thanks for the nice words
you are amazing mam....plz keep flowing such knowledge with us..
Thanks a lot Pranay🙂👍
Thanks mam....
Your explanation made the topics very easy to understand.
Thanks Sanjay 👍👍
Can you please share any ppt with code snippets.it will be very useful to revise
Do u have any classes or course as well. I never commented before on TH-cam. Your videos are amazing
Hey Astha Thanks for commenting. 👍No Astha We don't have any paid courses or classes, everything is on TH-cam 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 TH-cam channel link to all my friends
this is very amazing channel, please continue your good work mam❤
Sure Lokesh you will see more videos on channel 😀
thanks for the content. but it would be great if you could share the github link for the code
She's awesome and very sweet☺
🙂🙂
Very Useful..thanks..
you're welcome
awesome training ...can you give the github code access for the same
Subscribed.... Thanks...
🙂🙂
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
your video is awesome
Thanks Ravi 😊👍
Amazing explanation
Thanks
Do we have a github repo link as a reference code of these tutorials
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.
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 👍👍
madam, please start real-time project from many days we are waiting for it
Thanks a lot to you
👍👍
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
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
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.
Please, do video on java 8 Consumer function also
We have it already 🙂👍
th-cam.com/video/7-ALyd6OAaQ/w-d-xo.html
th-cam.com/play/PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy.html
IS there any link from where we can download these ppts ?
great videos!!
Thanks
hi please explain the git and interview question also
Great effort Mam
Thanks Joseph 🙂👍
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.