What is the catch or declare rule for method declarations?
Answer / amit2009mca
the catch and decalre rule to handle the exception
1)when we don't want to handle the particular exception
we declare it
means to say that imagine that you go to market class
and call the purchase method to purchase a book.
but the shopkeeper has n't the particular book so its
responsibility to shopkeeper that he inform you about
particular exception so he declare the exception
Booknotfound and throws like this
class Market
{
public void purchase throws booknotfound
{
}
}
so this is called the declare rule
another is
2)catch
imagine you call the purchase method to buy book but there
is some problem like book is tore up or book is in godown
so its peoblenm pf the sopkeeper so its responsibility of
shopkeeper to handle this particular exception
then the Catch rule comes in a ligtht
like theis
class Narket
{
public purchase()
{
try{
}
catch(Booktoreupexception e or BookinstoreException e)
{
}
thanks if you got this because these all are just for
checked exception thanks
AMIT SINGH09(amitsing2008@gmail.com) thanks
Is This Answer Correct ? | 3 Yes | 0 No |
Can applet in different page/s communicate with each other?
What are the benefits of operations in java?
What's a method in programming?
How many types of string data types are there?
Variables used in a switch statement can be used with which datatypes?
Write POJO class as a key to hashmap???
Is it possible to override the main method?
Why we use set in java?
Can I extend singleton class in java?
hi am an engineering student and my next plan is for ms in either in us or australia i got my passport but i dont know anything bout visa can u give brief idea 1)How to get prepared for visa and 2)How to apply for top universities and 3)How to pay the fee and so on These all are basic questions plz give me a clear idea
Given: 1. package test; 2. 3. class Target { 4. public String name = “hello”; 5. } What can directly access and change the value of the variable name? 1 any class 2 only the Target class 3 any class in the test package 4 any class that extends Target
Explain Global variables in Packages?