Posts

SQL Interview Questions

 What is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN? Explain with examples. Table: Employees EmpID EmpName DeptID 1         Alice         10 2        Bob                 20 3       Charlie         NULL 4       David         30 Table: Departments DeptID DeptName 10         HR 20         IT 40         Finance 1. INNER JOIN ------------- Returns only the matching rows from both tables. Non-matching rows are excluded. EX: SELECT e.EmpName, d.DeptName FROM Employees e INNER JOIN Departments d ON e.DeptID = d.DeptID; Result: EmpName DeptName Alice         HR Bob                 IT 2. LEFT JOIN (LEFT OUTER JOIN) ------------------------...

Java Input Output Streams

 What the actual functionalities of OOS and OIS? Performing serialization and deserialization What is Serialization? Serialization is the process of Converting an object into stream of bytes and sending them to underling outputstream. Using serialization we can store object state permanently in a destination EX: File or Remote Computer(RMI, Socket Programing). Serialization operation is performed by writeObeject(). What is Deserialization? Deserialization is the process of Converting stream of bytes into original object. Deserialization operation is performed by readObeject(). Rule on Serialization? Serializable is a marker interface.  only Serializable type objects are serializable. It provides special permition or identity to JVM to serializable object. If the given object isn't type serializable interfacethen writeObeject() will  throw an unchecked exception called NotSeriableException. What are the methods with serializable interface? No methods are there in serializa...

Java 8 Interview Programs

  Find the first non-repeating character in a String using Java 8 javabestinterviewquestion.blogspot.com import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; public class Main {     public static void main(String[] args) {         String input = "programming";         Character result = input.chars()                 .mapToObj(c -> (char) c)                 .collect(Collectors.groupingBy(c -> c, LinkedHashMap::new, Collectors.counting()))                 .entrySet().stream()                 .filter(e -> e.getValue() == 1)                 .map(Map.Entry::getKey)                 .findFirst()                 .orElse(...

java 8 interview questions

 Core Java 8 Features ==================== What are the main features introduced in Java 8 ? Lambda Expressions Functional Interfaces Stream API Default and Static Methods in Interfaces java.time (New Date and Time API) Optional class Method references and constructor references Lambda and Functional Interfaces What is a functional interface? Can you create a custom one? Interface with a single abstract method (SAM). Use @FunctionalInterface annotation. Difference between Predicate, Function, and Consumer interfaces? Predicate<T> – returns boolean Function<T,R> – returns a result Consumer<T> – consumes and returns nothing How does lambda expression improve code readability or performance? Streams and Collections What is the difference between map() and flatMap() in Streams? map() transforms each element. flatMap() flattens nested streams. How does Stream API help in functional-style programming? Explain lazy evaluation in streams with examples. What are terminal v...