Java Programming Question
Java Programming Question
(b) What is the difference between method overloading and method overriding?
(c) The abstract vegetable class has three subclasses named Potato, Brinjal and Tomato.
Write a java program, that demonstrates how to establish this class hierarchy. Declare
one instance variable of type String that indicates the color of a vegetable. Create and
display instances of these objects. Override the toString() method of object to return a
string with the name of vegetable and its color. (4+3+7)
7. (a) What is exception? How can you handle the exception in Java? Explain.
(b) What is user-defined exception? Explain with a suitable program.
(c) Explain the difference between „throw‟ and „throws‟ with a suitable example.
(d) What is the use of “finally” keyword? (4+4+3+3)