This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!

Swapna latha

Ranch Hand
+ Follow
since Dec 18, 2011
Swapna likes ...
jQuery Eclipse IDE
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swapna latha

Tim Holloway wrote:An Interface is a contract. If a class implements an Interface, then it has promised that it will have implemented all of the methods defined in the Interface.

That's useful for a number of reason, including plug-replaceable components. And in particular test components.

If you have an interface definition you can construct a dummy or mock class that implements the indicated methods but does not have to actually do all the work that the "real" class does. That means that you can test your team's code without having to wait for the other team to deliver the "real" class.

Note that I distinguish between a "dummy" class and a "mock" class. In this context, a dummy class is simply a class that you implement yourself to test with. A Mock class is usually controlled by a mocking framework. Given a choice, I prefer dummy classes, but a mocked class can often be used in an environment where you need to pretend to connect to complex infrastructure and a dummy class can't be used.

Agreed. Let me frame and example on that. Correct me if i am going wrong

public class House{};
public class RedHouse extends House{}
public class BlueHouse extends House{}

public interface Student{

House getHouse(List<House> houses, String studentLastName);


dummy class :

public class StudentImpl imlements Student{

List<Houses> houses = new ArrayList<>();

House getHouse(houses, "lastName"){
return houses.get(0);


My team can use this  dummy class for testing and can write about House, RedHouse, BlueHouse etc.,

The other team can write the exact logic for getHouse with students last name and the houses list for a school. The other team will write the implementation of StudentImpl with business rules

Thus both teams can be engaged with interface as centric.

1 month ago
Hi Team,

I was just going through the Java 1.8 OCP book by Jeanne and Scott and there they mentioned about mock interface so that two different teams can do programming and join their code later.

I am not clear about the example quoted in the book , could any one please help me with few different and easily understandable examples.

Best Regards,

Swapna Kori
1 month ago
Hi All,

I am really confused in applying lambda map function where as the code which i am reading has got the result.

What i am doing wrong ? Please guide me .

Thanks & Regards,

2 years ago
Hi, I am working on few examples on Threads and i do see that Thread class has an Functional interface inside it.

I have seen an example in an udemy course like:

Could any one please exaplain the advantage of functional interface in a class.

Stephan van Hulst wrote:On a tangent: In general you don't need to worry about the A parameter. You only need to care about it if you implement your own Collector.

Thank you Stephan.
Thank you very much Tim. I got the answer now.

Tim Holloway wrote:Try this with 1:59 instead of 2:00. You might find it interesting. Indeed, try 1:59:59

Campbell Ritchie wrote:But Comparator is a functional interface.

Got it Campbell. Thank you very much.
But I have used BiFunction above. Comparator is not a Bifunction right.

Campbell Ritchie wrote:But Comparator is a functional interface.

Campbell Ritchie wrote:Have you seen the documentation for Collections#sort()?

Yes Campbell, it takes the second argument as Comparator but not function. So confused at this part.

Thanks & Regards,


Stephan van Hulst wrote:You need to tell us what part of the explanation is not clear to you, and explain to us why you think it is 0.

Stephan, the lines of codes are as follows with my explanation . Correct me if i am wrong

LocalDateTime ld1 = LocalDateTime.of(2015, Month.NOVEMBER, 1, 2, 0); // This line of code is having a time of 2 AM so as per DST savings, it should become 1 AM
ZonedDateTime zd1 = ZonedDateTime.of(ld1, ZoneId.of("US/Eastern"));
LocalDateTime ld2 = LocalDateTime.of(2015, Month.NOVEMBER, 1, 1, 0);// There wont be any change of time as the time is still 1 AM and time changes after 2 AM
ZonedDateTime zd2 = ZonedDateTime.of(ld2, ZoneId.of("US/Eastern"));// As both the times are 1 AM , the result is zero.

Thanks & Regards,

Hi All,

I am practising questions from both enthuware and whizlab and i have got struck in understanding how does sort method takes function as 2nd argument.

Question is how function as 2nd argument to sort method.

Thanks & Regards,


Stephan van Hulst wrote:What part don't you understand?

Stephan, I am not sure how the answer is -2. I still think answer is 0. The explanation given by enthuware is not clear to me.

Thanks & Regards,

I am practising enthuware questions and i got confused in one of the question and is as follows:

The options are :
This will not compile.

When i have chosen it as 0 , but i see that that answer from enthuware is -2.

Explanation by enthuware software guys is as follows:

Think of it as follows -
The time difference between two dates is simply the amount of time you need to go from date 1 to date 2.
So if you want to go from 1AM to 2AM, how many hours do you need? On a regular day, you need 1 hour. That is, if you add 1 hour to 1AM, you will get 2AM. However, as given in the problem statement, at the time of DST change, 2 AM becomes 1AM. That means, even after adding 1 hour to 1AM, you are not at 2AM. You have to add another hour to get to 2 AM. In total, therefore, you have to add 2 hours to 1AM to get to 2AM.

The answer can therefore be short listed to 2 or -2. Now, as per the JavaDoc description of the between method, it returns negative value if the end is before the start. In the given code, our end date is 1AM, while the start date is 2AM. This means, the answer is -2.

I am not clear about the explanation of Enthuware guys


Hi All,

I am practising OCP questions by Enthuware and the code is as follows:

Can we reuse the stream as i used stream once with dList and also the second time.

Thanks & Regards,