
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

4K+ Views
In Java, a constructor refers to a special method within a class that is always executed automatically while creating an instance of the class using the new keyword. Its main purpose is initializing the object by providing its fields with initial values so that it is ready for use. A constructor shares the name of the class itself, has no return type, and can be overloaded so that there will be different ways of initializing the objects. If you don’t provide one, Java inserts a default no-argument constructor automatically. What is a Constructor Reference in Java? Constructor reference is like ... Read More

7K+ Views
In multithreading environment, two or more threads can access the shared resources simultaneously which can lead the inconsistent behavior of the system. Java uses concept of locks to restrict concurrent access of shared resources or objects. Locks can be applied at two levels −Object Level Locks − It can be used when you want non-static method or non-static block of the code should be accessed by only one thread.Class Level locks − It can be used when we want to prevent multiple threads to enter the synchronized block in any of all available instances on runtime. It should always be used ... Read More

9K+ Views
In this article, we are going to learn about implementing a constructor reference with an argument or multiple arguments in Java. Constructor references in Java provide us with a concise way of creating new objects via method references. These are going to enable us to reference a constructor without running the constructor itself so the code looks cleaner and it will be more readable. What is a Constructor Reference? A method reference may also be used with Java 8 constructors. A constructor reference may be defined by employing the class name and a new keyword. The constructor reference may be ... Read More

8K+ Views
In this article, we will learn about the ConcurrentHashMap and HashTable in Java. First, we will know about ConcurrentHashMap, the syntax of ConcurrentHashMap, and an example after that will learn about HashTable, the syntax of HashTable, and an example. At the end, we will see a table showing the difference between ConcurrentHashMap and HashTable. What is ConcurrentHashMap in Java? ConcurrentHashMap is a class that was introduced in JDK 1.5. The ConcurrentHashMap is threadsafe as it allows multiple threads to read and write the data without locking the entire map. ConcurrentHashMap applies locks only at the bucket level, called a fragment, while ... Read More

10K+ Views
Hibernate or JPA support 4 different types of primary key generator. These generators are used to generate primary key while inserting rows in the database. Below are the primary key generator −GenerationType.AUTOGenerationType. IDENTITYGenerationType.SEQUENCE GenerationType.TABLEGenerationType. IDENTITY − In identity , database is responsible to auto generate the primary key. Insert a row without specifying a value for the ID and after inserting the row, ask the database for the last generated ID. Oracle 11g does not support identity key generator. This feature is supported in Oracle 12c. GenerationType. SEQUENCE − In sequence, we first ask database for the next set of the sequence ... Read More

928 Views
In this article, we will learn about the EnumMap and HashMap in Java. First, we will know about EnumMap, the syntax of EnumMap, and an example after that will learn about HashMap, the syntax of HashMap, and an example. At the end, we will see a table showing the difference between EnumMap and HashMap. What is EnumMap? EnumMap is introduced in JDK 5. It is designed to use an Enum as a key in the Map. It is an implementation of the Map interface. All of the keys in the EnumMap should be of the same enum type. Keys cannot be ... Read More

934 Views
Collection.stream().forEach() and Collection.forEach() both are used to iterate over collection. Collection.forEach() uses the collection’s iterator. Most of the collections doesn’t allow the structurally modification while iterating over them. If any element add or remove while iteration they will immediately throw concurrent modification exception. If Collection.forEach() is iterating over the synchronized collection then they will lock the segment of the collection and hold it across all the calls. Collection.stream().forEach() is also used for iterating the collection but it first convert the collection to the stream and then iterate over the stream of the collection therefore the processing order is undefined. It also throws ... Read More

22K+ Views
Save() and persist() both methods are used for saving object in the database. As per docs −Save() − Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".As per docs −persist() − Make a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist". The semantics of this method are defined by JSR-220. Sr. No.Keysave()persist()1Basic It stores object in databaseIt also stores object in database2Return Type It return generated id and return type is ... Read More

6K+ Views
JDBC is acronym of Java database connectivity. It is used to connect your application to the database and transactions . It is an open source Java api. Hibernate is also used for connect your application to database and to do database related transactions but with different approach. It has a object relationship library which mapped the tables and columns of the database with the java object. It enables object oriented programming in database. Hibernate provides HQL to access the data from the database. Sr. No.KeyJDBCHibernate1Basic It is database connectivity technology It is a framework, 2Lazy Loading It does not support lazy loading Hibernate support ... Read More

26K+ Views
In hibernate, get() and load() are two methods which is used to fetch data for the given identifier. They both belong to Hibernate session class. Get() method return null, If no row is available in the session cache or the database for the given identifier whereas load() method throws object not found exception. Sr. No.KeyGet()Load()1Basic It is used to fetch data from the database for the given identifier It is also used to fetch data from the database for the given identifier 2Null Object It object not found for the given identifier then it will return null object It will throw object not found exception 3Lazy ... Read More