Q.What is the alternative to null in Java? Java 8 introduces a new class called java.util.Optional<T> that’s inspired by the ideas of Haskell and Scala. It’s a class that encapsulates an optional value. Q.How do you model the absence of a value?...
Read MoreSunday, 22 September 2019
Saturday, 21 September 2019
Double colon operator
Method and Constructor reference by using "::" operator The functional interface method can be mapped to our specified method by using "::" operator. This is called method reference. Our specified method can be either a static or instance method. The functional interface...
Read MoreJava 8 in built functions
IN BUILT FUNCTIONS Consumer,Supplier,Function and Predicate all are available under java.util.function package. Comparison of in built functions Properties Consumer Supplier Function Predicate Purpose To consume some input and perform required operation.It won’t return anything To supply some value base on requirement To...
Read MoreFriday, 20 September 2019
Default method
Default Methods In Java 1.8v onwards, you can also define the default method inside the interface. You can define the default method using the keyword default. Default methods are by default available to all implementation classes. Based on our business requirement implementation...
Read MoreTuesday, 17 September 2019
Generic concept
Agenda Introduction Generic Classes Bounded types Generic methods and wild card character Conclusion Introduction The generic concept is introduced in Java 1.5v To resolve two problems of collection. Type safety ClassCastException ArrayList list = new ArrayList();//Non generic a.k.a raw type version till...
Read MoreException handling
Agenda Exception Exception Handling Benefits of Exception Handling Hierarchy of Exception Keywords related to exception Default exception handling in java The possible combination of try, catch and finally Multi-catch block Try-with resources Custom Exception Assertions Exception An event that disturbs the normal...
Read More