Posts

Showing posts with the label Java Interview

Java Interview Prep: Mastering Static and Final Keywords

Image
When preparing for a Java interview, understanding static and final keywords is essential, as they are frequently discussed. Below is an overview of what static and final mean in Java, along with some examples and interview-style questions to help with your preparation. Understanding static and final in Java 1. static Keyword: Definition : The static keyword is used to declare class-level members. When a method or variable is marked as static , it belongs to the class rather than an instance of the class. Usage : Static Variables : These are shared by all instances of the class. There's only one copy of the static variable for all objects. Static Methods : These belong to the class itself, so they can be called without creating an instance of the class. Static methods can only access static members of the class. Static Block : This is used for static initialization of a class. It is executed once when the class is loaded into memory. Example : class Example { static ...

10 Common Java Interview Questions Related to the Stream API

Java interview questions related to streams are often focused on practical usage of the Stream API introduced in Java 8. Some of the most common practical questions include: 1. Filtering a List Problem: Given a list of integers, filter out the even numbers and return a list of odd numbers. Solution: import java.util.Arrays ; import java.util.List ; import java.util.stream.Collectors ; public class Main { public static void main ( String [] args) { List < Integer > numbers = Arrays . asList ( 1 , 2 , 3 , 4 , 5 , 6 ); List < Integer > oddNumbers = numbers .stream() .filter(n -> n % 2 != 0 ) .collect( Collectors . toList ()); } } 2. Mapping a List Problem:  Given a list of strings, convert all strings to uppercase. Solution: import java.util.Arrays ; import java.util.List ; import java.util.stream.Collectors ; public class Main { public static void main ( String [] args) { List < String > words =...

Top 50 Hibernate Interview Questions and Answers - Frequently Asked - 2024

Image
1. What is Hibernate? Hibernate is the most popular open-source Java ORM framework in use today. Hibernate allows you to map plain old Java objects to relational database tables. Hibernate also provides data query and retrieval facilities. Hibernate generates the SQL calls and attempts to relieve the developer from manual result set handling and object conversion and keep the application portable to all supported SQL databases.  2. What is ORM? ORM sets the mapping between the set of objects which are written in the preferred programming language like Java and relational database like Oracle. It hides and encapsulates the SQL queries into objects and instead of SQL queries, we can use directly the objects to implement the SQL query. 3. What are the major advantages of Hibernate Framework? Hibernate framework is an open-source framework.  Hibernate framework is a high-performance framework because of its internal cache. Provides facilities to automatically create a table. It pr...