1. Differentiate between throw and throws keywords in java using an appropriate program.
2. What is the difference between checked and unchecked exception? What are the different ways of handling checked exceptions in Java?
3. What is the significance of using finally block in exception handling? How it is different from the catch block? Explain the importance of finally with the help of a suitable program.
4. Write a Program in which prompt the user to enter a String. If the
size of String is odd, then throw a User-defined exception
InvalidStringException and display "String is Not Accepted". Re-throw
the caught exception from catch block to print "Thanks for using this
Program".
5. Write a program to define a class named Car with an attribute
fuel, and constants mileage and max_fuel. Provide the following
methods:
public int addFuel(int ltr) throws FuelTankFullException
public void travel(int km) throws NotSufficientFuelException
such that if the added fuel(ltr) is greater than max_fuel then a user defined exception FuelTankFullException is thrown and when the fuel is not sufficient to travel km distance then NotSufficientFuelException is thrown.
In main class create a Car object. Invoke the addFuel and travel methods. In travel method, handle the NotSufficientFuelException such that it asks the user to add the fuel.
COEPD LLC - Center of Excellence for Professional Development is the most trusted online training platform to global participants. We are primarily a community of Business Analysts who have taken the initiative to facilitate professionals of IT or Non IT background with the finest quality training. Our trainings are delivered through interactive mode with illustrative scenarios, activities and case studies to help learners start a successful career. We impart knowledge keeping in view of the challenging situations individuals will face in the real time, so that they can handle their job deliverables with at most confidence.
ReplyDeletecoepd.us/index.html
where is the answer
ReplyDeleteGood Post! Thank you so much for sharing the post, it was so good to read and useful to improve
ReplyDeleteJava Training in Electronic City