Singleton design pattern



Singleton pattern is a design solution where an application wants to have one and only one instance of any class.It saves memory because object is not created with each request. Only single instance is reused again and again.
But how to make any class singleton is not so easy task, because there are several way in which singleton can break.
Steps:
1.      Make constructor private, so not directly instantiated class
2.      Make a static method which produce existing instance if one available else new
3.      Override clone() method. One cannot create a cloned object which also violates singleton pattern.
4.      If Singleton is class is serializable then once it serialized again deserialized it, but it will not return singleton object.

Difference between Java 8 interface and Java 7 interface



Before Java 8, interface having only abstract methods that means method without body (implementation). But Java 8 interface can contain abstract method as well as default implemented method and interface level method (static method). That means now in Java 8 interface can contain three types of methods.

A new date and time API has been designed for Java SE 8.



There are several problems with existing Date and Time API some of them are-
1. The existing classes (such as java.util.Date and SimpleDateFormatter) aren’t thread-safe
2. Poor API design. E.g. years in java.util.Date start at 1900, months start at 1, and days start at 0.