1.There arefivekeywords in Java that are related only toexceptions. List them and explain what they mean.
2.Method long factorial(short n) shall calculate and return the factorial of a non- negative number n. If n is negative, the method shall throw a NegativeNumberException. Write a complete iterative or recursive implementation of this method.
3. Write a definition of a class that represents a scheduled airflight. (You have to come up with a good class name.) The class shall have five private data fields: short flight number, three-letter origin and destination airposrt codes (e.g., "BOS"), and departure and arrival times as byte hours (no minutes).
The class shall have a constructor that takes the five previously mentioned parameters; checks if the flight number and hours are non-negative, the airport codes differ from each other, and the departure time is before the arrival time; and initializes the data fields. If any of the conditions is false, the constructor shall throw a BadData exception.
The class shall have public method byte duration() that shall return the flight duration, in hours.
Write a small code fragments that shall create an instance of your class and print the duration of the flight.
4.What is a static variable?
5.Public class Animal has attribute short age. Public class Bear is a subclass of Animal. It imlements method void sleepAndAge() that, among other things, increments the bear's age: age++;. What should be the visibility attribute of age in the parent class for this method to be compilable? Write the complete definition of age, as you would see it in the Animal class.
Class Animal has an abstract method abstract void feed(double food);. Write the complete headers of both classes mentioned in the problem. Do not write the bodies of the classes.
6.How to make a class immutable?
7. What happens to the content of an existing writable file if the file is used with a
PrintWriter?
8. Classes Circle, Box, and Triangle are subclasses of an abstract class Shape. Declare an array of five shapes and initialize it with two circles, two triangles, and a box. (Assume that each of the classes has a constructor with no parameters.)
Class Shape has method double area(). Write a code fragment that shall display the areas of all the shapes from the previously declared and initialized array.