• Java
    • JAXB Tutorial
      • What is JAXB
      • JAXB Marshalling Example
      • JAXB UnMarshalling Example
  • Spring Tutorial
    • Spring Core Tutorial
    • Spring MVC Tutorial
      • Quick Start
        • Flow Diagram
        • Hello World Example
        • Form Handling Example
      • Handler Mapping
        • BeanNameUrlHandlerMapping
        • ControllerClassNameHandlerMapping
        • SimpleUrlHandlerMapping
      • Validation & Exception Handling
        • Validation+Annotations
        • Validation+ResourceBundle
        • @ExceptionHandler
        • @ControllerAdvice
        • Custom Exception Handling
      • Form Tag Library
        • Textbox Example
        • TextArea Example
        • Password Example
        • Dropdown Box Example
        • Checkboxes Example
        • Radiobuttons Example
        • HiddenValue Example
      • Misc
        • Change Config file name
    • Spring Boot Tutorial
  • Hibernate Tutorial
  • REST Tutorial
    • JAX-RS REST @PathParam Example
    • JAX-RS REST @QueryParam Example
    • JAX-RS REST @DefaultValue Example
    • JAX-RS REST @Context Example
    • JAX-RS REST @MatrixParam Example
    • JAX-RS REST @FormParam Example
    • JAX-RS REST @Produces Example
    • JAX-RS REST @Consumes Example
    • JAX-RS REST @Produces both XML and JSON Example
    • JAX-RS REST @Consumes both XML and JSON Example
  • Miscellaneous
    • JSON Parser
      • Read a JSON file
      • Write JSON object to File
      • Read / Write JSON using GSON
      • Java Object to JSON using JAXB
    • CSV Parser
      • Read / Write CSV file
      • Read/Parse/Write CSV File – OpenCSV
      • Export data into a CSV File
      • CsvToBean and BeanToCsv – OpenCSV

JavaInterviewPoint

Java Development Tutorials

Spring Data REST Example – Spring Boot RESTful API + CRUD

July 24, 2019 by javainterviewpoint Leave a Comment

Spring Data REST is built on top of the Spring Data repositories and it automatically exposes the repositories as REST services. Spring Data REST takes the features of Spring HATEOAS and Spring Data JPA and combines them together, using a Strategy called “RepositoryDetectionStrategy” to export the repository as a REST resource. In this Spring Data REST Example, let’s create a Spring Boot RESTful API and perform CRUD Operations

It uses the HATEOAS (Hypermedia As The Engine Of Application State) principle and supports HAL (Hypertext Application Language). HATEOAS principle is that each resource should have its own URI / endpoint and it is the basic rule which all the RESTful Web Services must follow.

Spring Data REST automagically creates a Spring REST Web Service without the need for us to explicitly write one. We will have to use spring-boot-starter-data-rest dependency along with spring-boot-starter-data-jpa in order to create the REST API

Let’s get started

Creating table

Create EMPLOYEE Table, simply Copy and Paste the following SQL query in the MySQL query editor to get the table created

CREATE TABLE EMPLOYEE
(
    ID INT NOT NULL AUTO_INCREMENT,
    FIRSTNAME VARCHAR(30),
    LASTNAME VARCHAR(30),
    PRIMARY KEY(ID)
);

insert into Employee (ID,FIRSTNAME,LASTNAME) values(101, 'John','Smith');
insert into Employee (ID,FIRSTNAME,LASTNAME) values(102, 'David','Jones');

Spring Data REST Example – Spring Boot RESTful API

Spring Data REST Example

Folder Structure:

Spring Data REST Example 1

  • Create a simple Maven Project “SpringDataRest” by selecting maven-archetype-quickstart  and create a package for our source files “com.javainterviewpoint” under  src/main/java 
  • Now add the following dependency in the POM.xml
    <project xmlns="http://maven.apache.org/POM/4.0.0"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    
    	<groupId>com.javainterviewpoint</groupId>
    	<artifactId>SpringDataRest</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    	<packaging>jar</packaging>
    
    	<name>SpringDataRest</name>
    	<url>http://maven.apache.org</url>
    
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<java.version>1.8</java.version>
    	</properties>
    
    	<parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.1.3.RELEASE</version>
    	</parent>
    
    	<dependencies>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-data-jpa</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-data-rest</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>mysql</groupId>
    			<artifactId>mysql-connector-java</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>com.fasterxml.jackson.core</groupId>
    			<artifactId>jackson-databind</artifactId>
    			</dependency>
    		<dependency>
    			<groupId>com.fasterxml.jackson.core</groupId>
    			<artifactId>jackson-annotations</artifactId>
    			</dependency>
    	</dependencies>
    
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
    </project>
  • Create the Java classes App.java, Employee.java and EmployeeRepository under com.javainterviewpoint folder.
  • Create application.properties file under src/main/resources directory and provide the MySQL Connection settings and JPA Properties
#MySQL Connection settings
spring.datasource.driver = com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=root

#JPA properties 
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

The spring-boot-starter-parent is a special starter, it provides useful Maven defaults.

spring-boot-starter-data-jpa uses Spring Data JPA with Hibernate as the implementation, which enables the easy implementation of JPA based repositories.

spring-boot-starter-data-rest has a specific purpose it help us to expose repositories as a REST services.

Other interesting articles which you may like …

  • Spring Boot Exception Handling – @RestControllerAdvice + @ExceptionHandler
  • Spring Boot Security Database Authentication
  • Spring Boot Security Basic Authentication
  • Spring Boot @ConfigurationProperties Example
  • Spring Boot auto-configuration @SpringBootApplication
  • Spring Boot Thymeleaf Example
  • Spring Boot JPA Tutorial
  • Spring Boot Tomcat JDBC Connection Pool
  • Spring Boot Logging – Logback
  • Spring Boot Log4j2 Example
  • Spring Boot HikariCP Connection Pool
  • Spring Boot JDBC Connection Pool
  • Spring Boot RESTful Web Services Example
  • Spring Boot Kotlin RESTful Web Services
  • Spring Boot with Kotlin Hello World Example
  • Spring Boot Hello World Example with Maven
  • Spring Boot Hello World Example in Eclipse
  • How to Create Deployable WAR | Spring Boot | SpringBootServletInitializer
  • Spring Boot Change Embedded Tomcat default port
  • Spring Boot CRUDRepository Example- Spring Data JPA
  • Fix missing src/main/java folder in Eclipse Maven Project
  • Spring MVC CRUD Example with MySql + JdbcTemplate
  • RESTful Java Client With Jersey Client
  • RESTEasy Hello World Example with Apache Tomcat
  • RESTful Java client with RESTEasy client
  • Spring RESTful Web Services Hello World XML Example
  • Springfox Swagger 2 for Spring RESTful Web Services

Dependency Tree

[INFO] ---------------< com.javainterviewpoint:SpringDataRest >----------------
[INFO] Building SpringDataRest 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ SpringDataRest ---
[INFO] com.javainterviewpoint:SpringDataRest:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  +- org.springframework.boot:spring-boot:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
[INFO] |  |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
[INFO] |  |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  |  |  \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] |  |  +- org.springframework:spring-aop:jar:5.1.5.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.9.2:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.3.RELEASE:compile
[INFO] |  |  +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.1.5.RELEASE:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.3.7.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.23.1-GA:compile
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.10:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] |  |  +- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] |  |  +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-context:jar:5.1.5.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-expression:jar:5.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:5.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:5.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-core:jar:5.1.5.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-jcl:jar:5.1.5.RELEASE:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.1.5.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-rest:jar:2.1.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:2.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-json:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
[INFO] |  |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.3.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.16:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.16:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.16:compile
[INFO] |  |  +- org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile
[INFO] |  |  |  \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  +- org.springframework:spring-web:jar:5.1.5.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-webmvc:jar:5.1.5.RELEASE:compile
[INFO] |  \- org.springframework.data:spring-data-rest-webmvc:jar:3.1.5.RELEASE:compile
[INFO] |     \- org.springframework.data:spring-data-rest-core:jar:3.1.5.RELEASE:compile
[INFO] |        +- org.springframework.hateoas:spring-hateoas:jar:0.25.1.RELEASE:compile
[INFO] |        +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] |        \- org.atteo:evo-inflector:jar:1.2.2:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.15:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
[INFO] \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] ------------------------------------------------------------------------

Employee.java

package com.javainterviewpoint;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.data.rest.core.annotation.RestResource;

@Entity
@RestResource
@Table(name="EMPLOYEE")
public class Employee
{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="ID")
    private Integer id;
    
    @Column(name="FIRSTNAME")
    private String firstname;
    
    @Column(name="LASTNAME")
    private String lastname;

	public Employee()
	{
		super();
	}

	public Employee(Integer id, String firstname, String lastname)
	{
		super();
		this.id = id;
		this.firstname = firstname;
		this.lastname = lastname;
	}

	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}

	public String getFirstname()
	{
		return firstname;
	}

	public void setFirstname(String firstname)
	{
		this.firstname = firstname;
	}

	public String getLastname()
	{
		return lastname;
	}

	public void setLastname(String lastname)
	{
		this.lastname = lastname;
	}
	
}

Our Employee class is our JPA entity class consisting of the getters and setters for the Employee class properties (id, firstname, lastname).

In the POJO class, we have used the below JPA Annotations.

  1. @Entity – This annotation will mark our Employee class as an Entity Bean.
  2. @Table – @Table annotation will map our class to the corresponding database table. You can also specify other attributes such as indexes, catalog, schema, uniqueConstraints. The @Table annotation is an optional annotation if this annotation is not provided then the class name will be used as the table name.
  3. @Id –  The @Id annotation marks the particular field as the primary key of the Entity.
  4. @GeneratedValue – This annotation is used to specify how the primary key should be generated. Here SEQUENCE Strategy will be used, as this the default strategy for MySQL

EmployeeRepository.java

package com.javainterviewpoint;

import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "employee", path = "employee")
public interface EmployeeRepository extends CrudRepository<Employee, Integer>
{

}

Spring Data JPA will create an implementation of EmployeeRepository automatically during runtime, all we need to do is just extend the CrudRepository. We have annotated the EmployeeRespository class with @RepositoryRestResource annotation, this annotation will map all the end points based on our repository.

App.java

package com.javainterviewpoint;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App 
{
    public static void main( String[] args )
    {
        SpringApplication.run(App.class);
    }
}

@SpringBootApplication annotation does the work of @EnableAutoConfiguration, @Configuration, and @ComponentScan annotations together

That’s it we have created our RESTful Web Services, Seriously, once we have created our Entity (Employee) and Repository (EmployeeRepository) we can throw request to our REST API

Let’s Run our Application!

Select the Project –>Run As –> Run Configuration –>Maven –> New Configuration. In the Main tab, key in the Goals as “spring-boot:run” and click on Run.

Use POSTMAN or any other Rest Client and hit on the url http://localhost:8080/ 

You will see the HATEOAS representation of all the available REST URLs

{
    "_links": {
        "employee": {
            "href": "http://localhost:8080/employee"
        },
        "profile": {
            "href": "http://localhost:8080/profile"
        }
    }
}
  • _links is part of the HAL, it exposes the links of the endpoints which is available.
  • employee is the Service which is created by Spring Data REST from our repository.
  • profile exposes the additional metadata information

Now hit on the URL http://localhost:8080/employee, it displays the list of the employees available.

{
    "_embedded": {
        "employee": [
            {
                "firstname": "John",
                "lastname": "Smith",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/employee/101"
                    },
                    "employee": {
                        "href": "http://localhost:8080/employee/101"
                    }
                }
            },
            {
                "firstname": "David",
                "lastname": "Jones",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/employee/102"
                    },
                    "employee": {
                        "href": "http://localhost:8080/employee/102"
                    }
                }
            }
        ]
    },
    "_links": {
        "self": {
            "href": "http://localhost:8080/employee"
        },
        "profile": {
            "href": "http://localhost:8080/profile/employee"
        }
    }
}

POST Request (Create)

We have already created 2 employees directly using SQL, let’s try creating the third employee using Spring Data Rest POST

Using POSTMAN, Place a POST Request by hitting the URL http://localhost:8080/employee with the below body and Content-Type:application/json

{
    "firstname": "Paul",
    "lastname": "Scholes"
}

Once we executed the above request, we will be getting 201 response code and the new employee which is created as a JSON

{
    "firstname": "Paul",
    "lastname": "Scholes",
    "_links": {
        "self": {
            "href": "http://localhost:8080/employee/1"
        },
        "employee": {
            "href": "http://localhost:8080/employee/1"
        }
    }
}

Spring Data REST Example - POST

GET Request (Read)

Using POSTMAN, Place a GET Request by hitting the URL http://localhost:8080/employee

We will be getting the below response, _embedded displays all the employees which is available in the database.

{
    "_embedded": {
        "employee": [
            {
                "firstname": "Paul",
                "lastname": "Scholes",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/employee/1"
                    },
                    "employee": {
                        "href": "http://localhost:8080/employee/1"
                    }
                }
            },
            {
                "firstname": "John",
                "lastname": "Smith",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/employee/101"
                    },
                    "employee": {
                        "href": "http://localhost:8080/employee/101"
                    }
                }
            },
            {
                "firstname": "David",
                "lastname": "Jones",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/employee/102"
                    },
                    "employee": {
                        "href": "http://localhost:8080/employee/102"
                    }
                }
            }
        ]
    },
    "_links": {
        "self": {
            "href": "http://localhost:8080/employee"
        },
        "profile": {
            "href": "http://localhost:8080/profile/employee"
        }
    }
}

POSTMAN - GET Request

PUT Request (Update)

Now let’s try to update the employee with id 1

Using POSTMAN, Place a PUT Request, hit the URL http://localhost:8080/employee/1 with the below body and Content-Type:application/json

we have added -edited to the lastname

{
    "firstname": "Paul",
    "lastname": "Scholes-edited"
}

we will be getting 200 response code and the updated employee as JSON

{
    "firstname": "Paul",
    "lastname": "Scholes-edited",
    "_links": {
        "self": {
            "href": "http://localhost:8080/employee/1"
        },
        "employee": {
            "href": "http://localhost:8080/employee/1"
        }
    }
}

POSTMAN - PUT Request

DELETE Request (Delete)

Let’s try deleting the employee with id 101

Using POSTMAN, Place a DELETE Request by hitting the URL http://localhost:8080/employee/101

We will be getting will get 204 No content response code, as the particular employee will not be available after delete

POSTMAN - DELETE Request

Searching

Till now we were able to search only with the employee id but Spring Data REST has the capabilities which allow you to search with different criteria as well.

Lets search with the below criteria

  1. With FirstName
  2. With Id and LastName

We need to a minor modification to our EmployeeRepository by adding the below methods.

package com.javainterviewpoint;

import java.util.List;

import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "employee", path = "employee")
public interface EmployeeRepository extends CrudRepository<Employee, Integer>
{
	List<Employee> findByFirstname(String firstname);
	
	List<Employee> findByIdAndLastname(Integer id, String lastname);
}

Spring REST will expose endpoints for the methods findByFirstName() and findByIdAndLastname()

1. With FirstName

Hit on the URL http://localhost:8080/employee/search/findByFirstname?firstname=David

Spring Data will automatically generate the query behind the scene “SELECT * FROM EMPLOYEE WHERE FIRSTNAME = ?”

Search - findByFirstname

2. With Id and LastName

Hit on the URL http://localhost:8080/employee/search/findByIdAndLastname?id=1&lastname=Scholes-edited

The query generated “SELECT * FROM EMPLOYEE WHERE ID= ? AND LASTNAME = ?”

Search - findByIdAndLastname

Hope this article helps you in getting the basic understanding of Spring Data REST. Happy Learning !!

    Download Source Code

Filed Under: Java, Spring, Spring Boot, Spring Data, Spring Tutorial Tagged With: HAL, HATEOAS, RESTful Web Services, Spring Boot, Spring Boot CRUD, Spring Data JPA, Spring Data REST, Spring Data REST Example

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Java Basics

  • JVM Architecture
  • Object in Java
  • Class in Java
  • How to Set Classpath for Java in Windows
  • Components of JDK
  • Decompiling a class file
  • Use of Class.forName in java
  • Use Class.forName in SQL JDBC

Oops Concepts

  • Inheritance in Java
  • Types of Inheritance in Java
  • Single Inheritance in Java
  • Multiple Inheritance in Java
  • Multilevel Inheritance in Java
  • Hierarchical Inheritance in Java
  • Hybrid Inheritance in Java
  • Polymorphism in Java – Method Overloading and Overriding
  • Types of Polymorphism in java
  • Method Overriding in Java
  • Can we Overload static methods in Java
  • Can we Override static methods in Java
  • Java Constructor Overloading
  • Java Method Overloading Example
  • Encapsulation in Java with Example
  • Constructor in Java
  • Constructor in an Interface?
  • Parameterized Constructor in Java
  • Constructor Chaining with example
  • What is the use of a Private Constructors in Java
  • Interface in Java
  • What is Marker Interface
  • Abstract Class in Java

Java Keywords

  • Java this keyword
  • Java super keyword
  • Final Keyword in Java
  • static Keyword in Java
  • Static Import
  • Transient Keyword

Miscellaneous

  • newInstance() method
  • How does Hashmap works internally in Java
  • Java Ternary operator
  • How System.out.println() really work?
  • Autoboxing and Unboxing Examples
  • Serialization and Deserialization in Java with Example
  • Generate SerialVersionUID in Java
  • How to make a class Immutable in Java
  • Differences betwen HashMap and Hashtable
  • Difference between Enumeration and Iterator ?
  • Difference between fail-fast and fail-safe Iterator
  • Difference Between Interface and Abstract Class in Java
  • Difference between equals() and ==
  • Sort Objects in a ArrayList using Java Comparable Interface
  • Sort Objects in a ArrayList using Java Comparator

Follow

  • Coding Utils

Useful Links

  • Spring 4.1.x Documentation
  • Spring 3.2.x Documentation
  • Spring 2.5.x Documentation
  • Java 6 API
  • Java 7 API
  • Java 8 API
  • Java EE 5 Tutorial
  • Java EE 6 Tutorial
  • Java EE 7 Tutorial
  • Maven Repository
  • Hibernate ORM

About JavaInterviewPoint

javainterviewpoint.com is a tech blog dedicated to all Java/J2EE developers and Web Developers. We publish useful tutorials on Java, J2EE and all latest frameworks.

All examples and tutorials posted here are very well tested in our development environment.

Connect with us on Facebook | Privacy Policy | Sitemap

Copyright ©2023 · Java Interview Point - All Rights Are Reserved ·