learnprograming byluckysir

Java 8 Real time Coding interview Questions
if anyone wants real time interview preparation and mock interviews
contact: luckyithub‪@gmail.com‬

Here are the sample task:

1. Let's say you have a list of Employee objects. Each employee has an age field. Can you write a stream-based code snippet to get all employees older than 30?
2. Suppose you have a list of products with name and price. How would you sort the products in ascending order of price using Java 8 streams?
3. Imagine some entries in your list might have null names. How would you sort the list but push all entries with null names to the end?
4. Can you show how to use a custom comparator within a stream to sort a list of objects, say, by length of their name fields?
5. What happens if two objects have the same length? How would you break the tie?
6. Assume a list of books where each book has a title and yearPublished. How would you sort the books by year, and then by title alphabetically in case of a tie?
7. You’re given a list of students. Filter out those who scored less than 60, then sort the remaining students by score in descending order. Can you implement this using streams?
8. You have a list of Order objects. Each order has a status field like 'DELIVERED', 'PENDING', or 'CANCELLED'. How would you use Java 8 streams to filter only the orders with status 'DELIVERED'?
9. Given a list of Product objects with fields like name, price, and unitsSold, how would you sort them in descending order of unitsSold and get the top 5 products?
10. You have a list of Customer objects, each with a list of Orders. How would you compute the total purchase amount for each customer and then sort the customers by that amount in descending order?
11. Let’s say each product has a discount field as a percentage. How would you filter out only those products with a discount greater than 30% and then sort them by discount descending?

5 months ago | [YT] | 9



@thedaily6388

Is it for tester questions or developers?

5 months ago | 0

@kumarabhishek7273

Hi sir, Can you guide me regarding career that what next I have to do for better switch. I have 5.6 yr of exp in manual testing

5 months ago (edited) | 0