Can you give me an example of method overriding?
- Method overriding occurs when a method is inherited from a parent class but the programmer changes its behavior to something else.
- An animal class has the method eat(). A dog class extending the animal class and will inherit the method eat(). But the dog however will change how it eats hence changing the behavior and overriding the eat() method.
How do you connect to a database using spring boot? [Good]
- Create a database with a username and password
- Insert tables and values into the database
- Create an application.yml file
- In the yml file, specify the url, username and password
- Your database is connected!!!! Yahooo!!!!!
How do you create a Rest API using spring boot?
- Create a Maven project and enter your GroupId and ArtifactId to reflect your project
- In the POM.xml file, create a parent and any other dependencies that you might need for your project
- Create a Model to represent your data [JPA]
- Create a REST controller to delegate http requests
- Create a service to provide any business logic.
- Create a repository marker interface which extends the jpaRepository to get access to methods to interact with the database
- Create a security config if you need it (Optional)
How to create a custom exception?
- You need to extend a the exception class
- If you need a runtime exception, then extend the RuntimeException