# 8) Problems

### Problem :

#### 1)

{% hint style="warning" %}


#### Do the following:

1. Create a class Book with id, name as the member variables.
2. Create  BookNotFoundException as a checked exception and   create one argument constructor which is accepting String message.
3. Create a test class with an array of 5 book with ids starting from 1.
4. Create a method findById(Book\[] books , int id) which will take the previously created book array and and one id to find the book.
5. Print "Found" if the book is present with the given id else throw BookNotFoundException with a message "Book with the given id is not present".
6. Handle the exception in main method and print the stacktrace in catch block.
{% endhint %}

### Coding Problem :

{% embed url="https://www.hackerrank.com/domains/java?filters%5Bsubdomains%5D%5B%5D=handling-exceptions" %}



{% embed url="https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/exception-handling-2-46f67551/" %}



{% embed url="https://www.techgig.com/practice/java/exception-handling" %}



{% embed url="https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/exception-handling-2-46f67551/" %}

## Quiz :

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpMyT7SfYugjqgJxQO%2F-LcpNkJQfqcYw8V2nYYp%2FScreen%20Shot%202019-04-19%20at%205.04.57%20PM.png?alt=media\&token=5f9f68d0-b742-4222-b942-ee5ec16e84a5)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpMyT7SfYugjqgJxQO%2F-LcpNo-iLdVLFt2USGc8%2FScreen%20Shot%202019-04-19%20at%205.05.05%20PM.png?alt=media\&token=27edfbe3-edf7-4268-8e06-71f5519c100f)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpX3fJGHZxtjL-6rtf%2FScreen%20Shot%202019-04-19%20at%205.05.13%20PM.png?alt=media\&token=509f7c86-540e-43f8-a398-40329b7bfb8f)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpXDPoBSz4uR6ADyew%2FScreen%20Shot%202019-04-19%20at%205.05.23%20PM.png?alt=media\&token=37198f88-e6f3-4846-8962-aaed90afbb2e)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpXqz9GsjSw2QX9RKJ%2FScreen%20Shot%202019-04-19%20at%205.05.33%20PM.png?alt=media\&token=8d0d221d-afe5-4c55-8f64-d838a3b9a15b)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpbXeM-oXJjsYtrd_u%2FScreen%20Shot%202019-04-19%20at%205.05.42%20PM.png?alt=media\&token=419e5f4d-d12c-4479-b6f9-cc5fec7c9ab4)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpbbDueGyStd4QWF-F%2FScreen%20Shot%202019-04-19%20at%205.05.50%20PM.png?alt=media\&token=147e4874-bac4-4d19-b125-706c64354556)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-Lcpbg6Bco8-6WWUCFK4%2FScreen%20Shot%202019-04-19%20at%205.05.59%20PM.png?alt=media\&token=3ec535f0-3c35-4b7b-9356-7e89db7acad6)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpbjoZ-TvdKfnuSaLq%2FScreen%20Shot%202019-04-19%20at%205.06.11%20PM.png?alt=media\&token=a2794f14-f905-4781-aa1a-139edcae069c)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-Lcpbmf_qokCmiZqcpna%2FScreen%20Shot%202019-04-19%20at%205.06.22%20PM.png?alt=media\&token=f81db054-42b8-4799-b219-b1a7f0134625)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpbraGe1-pSfsvRt0o%2FScreen%20Shot%202019-04-19%20at%205.06.31%20PM.png?alt=media\&token=a9ede656-7d5e-42ae-b284-c1969b81c839)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-LcpbuHvZGA8woQh7Owc%2FScreen%20Shot%202019-04-19%20at%205.06.38%20PM.png?alt=media\&token=106b55c9-c310-4cca-be78-1109dd3bad70)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-Lcpby0B5fyfC801sc1G%2FScreen%20Shot%202019-04-19%20at%205.06.55%20PM.png?alt=media\&token=50d37a86-92d7-49f1-9fe4-89c6541eefcc)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-LcpWwHcFfwhRDi2nJZs%2F-Lcpc-THOP9mH9ADhd1U%2FScreen%20Shot%202019-04-19%20at%205.07.02%20PM.png?alt=media\&token=30e1afc4-8958-4b51-94d3-87700fa58bb3)

