Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Method decleration in java

Have Programming Question? Ask it here!
 
 
 


samar
Method decleration in java
1 Answer(s)      3 years and 11 months ago
Posted in : Java Interview Questions


What is the catch or declare rule for method declarations?

Advertisement
View Answers

October 26, 2010 at 4:32 PM


Hi,

Here is the answer.

If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

This rule is actually for handling the exceptions: that is there are two ways by which we can handle the exception :

1: either you use the try catch statement and enclose the appropriate code in the try catch block this is called as the catch or the handle rule.

2: you can also use the throw and throws statement instead of using the try catch block i.e you should specify the exceptions that your method is capable of throwing(only checked).

Thanks.



Related Tutorials/Questions & Answers:
Method decleration in java
Method decleration in java  What is the catch or declare rule for method declarations
java method
java method  can we declare a method in java like this static { System.loadLibrary("nativelib"); } i have seen this in a java learning E book. i don't understand the static { } plz help me. what kind of method
Advertisements
pass method reference in java
pass method reference in java  How to pass method reference in Java
java method - Java Beginners
java method  Plz help me on toString() in java  Hi Friend, The Object class provides the method toString() that returns the string..., the toString() method of the object is automatically called. Thanks
java method - Java Beginners
java method  i wanna explation about a method for example... Mail[] getAllMails(String userName) I WANNA EXPLATION ABOUT ABOVE METHOD CAN U... and Tutorials on Java Mail visit to : http://www.roseindia.net/javamail/ Thanks
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java
Using throw in java method
Using throw in java method  using throw with method implies what
try catch method in java
try catch method in java  try catch method in java - when and how should i use the try and catch method in Java ?   Please visit the following links: http://www.roseindia.net/help/java/t/java-try.shtml http
Java making a method deprecated
Java making a method deprecated  java making a method deprecated In Java how to declare a method depricated? Is it correct to use depricated... or method in Java. Instead of it you can use alternatives that exists. Syntax
Generic Method - Java Beginners
Generic Method  I want simple java program for Generic Method with explanation
getch() method in java
getch() method in java  does someone know how can i obtain the getch() function in java
Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How
java method - Java Beginners
java method  hi friends, Is there any default return type for methods in java?  There is no default return type in java, as a user you have to specify the return type even void
Class and method question, Java?
Class and method question, Java?  Consider a Java class that you... Prompt string** and the following method: getValue displays the prompt and reads..., the method should display an error message and ask the user for a new value
getch() method in java
getch() method in java  does someone know how can i obtain the getch() function in java?   Hi Friend, In java, you can use the method next() of Scanner class. Here is an example: import java.util.*; class Hello
Method overloading in java program
Method overloading in java program  How can we use method overloading in java program?   Method overloading:?In method overloading methods have same name but different type of parameters. Here is an example of method
Finalize method - Java Beginners
method, please can you suggest me a way out.   Hi method, finalize : Every class inherits the finalize() method from java.lang.Object the method... to the object exist the Object finalize method performs no actions but it may
method overloading - Java Beginners
method overloading   Write a program to demonstrate the method... }  Hi Friend, In Java, the methods having the same name within... is referred to as Method Overloading. In the given example, we have defined
Destroy method in java - Java Beginners
Destroy method in java  Hi, What is the implementation of destroy method in java.. is it native or java code? Thanks   Hi Friend, This method is not implemented. Thanks
Java Method with arrays
Java Method with arrays  My assignment is to write a java method..., write a program to test your method. my main method code is : public class...]; currentSmallestIndex = i; } } return currentSmallestIndex; } //main method
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
Static method in java - Java Beginners
Static method in java  What are static method in Java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml Hope that it will be helpful for you
customize method in java
customize method in java  hi there i want to create one customize method in which any no of parameters can be pass e.g the limit is 13 and if user wants to enter 3 inputs then that much can only be proceed so can i have solution
Java synchronized method
Java synchronized method  What are synchronized methods and synchronized statements
Java static method
Java static method  Can we override static methods
Java Method Overloading - Java Beginners
Java Method Overloading  can method be overloaded in subclass or not?  Hi Friend, Yes A subclass can overload the methods.For Example...: http://www.roseindia.net/java/master-java/method_overloading.shtml Thanks
method - Java Beginners
method  Method Sir, I am confusing in this sentence and did not understood clearly about a method that returns object and reference and unable.... Suppose, for instance, that you want to write a method to return what
Finalize method in Java - Java Beginners
Finalize method in Java  Hi, What is the use of Finalize method in Java? Give me few example of Finalize method. Thanks   Hi Friend, Java uses finalize() method for Garbage collection. Example: import
calling method - Java Beginners
calling method   class A{ public void fo(){ class B{ public void fo1(){ System.out.println("fo1 of class B... static void main(String args[ ]){ } } I Want to call method fo1
clone method - Java Beginners
clone method  I want to copy a reference which the class name is B and the variable name is A. I used clone method.After I have the class name C which is same with b class. C=(A) B.cloneObject(); I make a clone method
Java Script location.replace method
Java Script location.replace method  Hi, What does `Print `{<SCRIPT LANGUAGE="JavaScript"> location.replace("} & urlpop & {","BOTTOM") </SCRIPT>} this mean as this is written in an Lotus Script agent and I
boolean method - Java Beginners
don't know how to throw in the boolean method in my main class. Notebook...; } Below is main class method: String itemNo = JOptionPane.showInputDialog
java program on recursive method
java program on recursive method  in how many ways can you make change for one dollar(100 cents) using pennies(1-cent coins), nickels(5 cents), dimes(10 cents),and quarter(25 cents)? the coins must add up to the exact total
what is ment by method signature in java.......
what is ment by method signature in java.......  what is ment by method signature in java.......   Hi Friend, The signature of a method is the combination of the method's name along with the number and types
When is java main method called?
When is java main method called?  When is java main method called? Please explain the main method in Java with the help of code.   In a java class, main(..) method is the first method called by java environment when
How to use charAt() method in Java?
How to use charAt() method in Java?  Hi, what is the correct way of using chatAt() method in Java? Thanks   The charAt() method in Java... at charAt() Method In Java. Thanks
Static Method in java with realtime Example
Static Method in java with realtime Example  could you please make me clear with Static Method in java with real-time Example
Clone method example in Java
Clone method example in Java       Clone method example in Java programming language Given example of java clone() method illustrates, how to use clone() method. The Cloneable
Java class method - Java Beginners
Java class method  I have created a method that's supposed to return a basetime value, returning a string value, the problem is that i need to have it return a basetime to use it later. How can i modify this code to have
java Method Error - Java Beginners
java Method Error  class mathoperation { static int add(int p,int q) { return(p+q... mathdemo.java:7: missing method body, or declare abstract static int
Java method Overriding
Java method Overriding       Below example illustrates method Overriding in java. Method overriding in java means a subclass method overriding a super class method. Superclass
Final method in java
Final method in java In this section we will learn about Final method in java. Final  keyword in java is used with class, variable and methods. If final is used with method that method will not be overridden in subclass, if final
Example of Hashset iterator method in java.
Example of Hashset iterator method in java. In this exmple of HashSet class,  you will see the use of iterator() method. It is used for traversing all...)); System.out.println("Element before clear method : " + obHashSet
createCustomer method in Java - Java Beginners
createCustomer method in Java  I'm just trying to add a createCustomers() to an existing code. I have all of my GUIs and it compiles, but I'm kind of stuck here. My code is as follows: import java.awt.*; import
Use of isReadOnly() method in java.
Use of isReadOnly() method in java. In this tutorial, we will see how to use of isReadOnly method in java. IntBuffer API : The java.nio.IntBuffer class... type Method Description static IntBuffer allocate
Example of Hashset size() method in java.
Example of Hashset size() method in java. The size() is a method of HashSet class. It is used to calculte the size of HashSet. The size of method is equal to total number of elements in HashSet Code: 
Use of rewind method in java.
Use of rewind method in java.       In this tutorial, we will explain the use of rewind() method of Buffer class. The ByteBuffer ...;In this example, The rewind method reset the position of buffer at zero. So you can
sleep method in thread java program
sleep method in thread java program  How can we use sleep method... example ,we have used sleep method. we are passing some interval to the sleep method .After that interval thread will awake.   public class test
Java draw triangle draw method?
Java draw triangle draw method?  hi how would i construct the draw method for an triangle using the 'public void draw (graphics g ) method? im...; Here is an example that draws a triangle using drawPolygon method. import
 

 

 

DMCA.com