GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 41 of 923    Print  
What is the catch or declare rule for method declarations
If a checked exception may be thrown within the body of a method, the method musteither catch the exception or declare it in its throws clause.


  
Total Answers and Comments: 1 Last Update: June 15, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 15, 2008 08:51:53   #1  
vegetto Member Since: June 2008   Contribution: 10    

RE: What is the catch or declare rule for method declarations
this rule is actually for handling the exceptions:

that is there are two ways by ehich u 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)

eg void MyMethod() throws IOEception,any other exception just separate them with commas................
{
   /*your code and throw statement at appropriate step that throws the exception
    and don't use the try catch statement in this case
 EG throw new MyException(arguments if any);
  this instantiates MyException class*/
}
 this is called as DECLARE RULE

 
Is this answer useful? Yes | No

 Related Questions

Objects that subclass the Observable class maintain a list of observers. When anObservable object is updated it invokes the update() method of each of its observers tonotify the observers that it has changed 
Latest Answer : Observer observe only those class which are Observable. ...

The setLayout() method is used to specify a container's layout. 

setBounds() 
Latest Answer : component.setBounds(-,-,-,-); ...

When a task invokes its yield() method, it returns to the ready state. When a task invokesits sleep() method, it returns to the waiting state. 
Latest Answer : yield method is mainly used to release the lock of resource and pull up in to steady state from wait pool. Sleep() will pull the thread to sleep for the given time. It will throws exception while trying to intrupt in b/w the sleep state ...

An object's finalize() method cannot be invoked by the garbage collector while the objectis still reachable. However, an object's finalize() method may be invoked by otherobjects. 
Latest Answer : No, reachable obejcts can not be garbage collected ...

The readLine() method returns null when it has reached the end of a file. 
Latest Answer : readLine() method of BufferReader class returns String and when it reaches the end of file file it returns null. ...

A native method is a method that is implemented in a language other than Java. 
Latest Answer : Informs the compiler that the method has been used in a non-java platform and used only with the methods. ...

If a checked exception may be thrown within the body of a method, the method musteither catch the exception or declare it in its throws clause. 
Latest Answer : this rule is actually for handling the exceptions:that is there are two ways by ehich u 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 ...

After a thread is started, via its start() method or that of the Thread class, the JVMinvokes the thread's run() method when the thread is initially executed. 
Latest Answer : Start method invokes it.It may or may not get executed immediately. ...

validate() 


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

What is Common Data Modeling Method

Common Data Modeling is one of the core considerations when setting up a business data warehouse. Any serious company wanting to have a data warehouse will have to be first serious about data models. Building a data model takes time and it is not unusual for companies to spend two to five years just
 

What is Data Integrity Rule

In the past, Data Integrity was defined and enforced with data edits but this method did not cope up with the growth of technology and data value quality greatly suffered at the cost of business operations. Organizations were starting to realize that the rules were no longer appropriate for the busi
 

What is codd’s rule

E.codd designed 12 rules that stated rules for database to be relational. 1. The Information Rule:For a database to be relational all information is represented as data values in tables. 2. The Rule of Guaranteed Access:The data represented in table by using table name, column name and primary key
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

JavaScript Window Object Open Method Part 2

JavaScript Window Object Open Method Part 2 In this JavaScript tutorial you will learn about JavaScript Window Object Open Method features of window object open method scrollbars status titlebar toolbar top width innerHeight innerWidth outerHeight outerWidth and hotkeys mosgoogle center scrollbars S
 

JavaScript Window Object Open Method

JavaScript Window Object Open Method In this JavaScript tutorial you will learn about JavaScript Window Object Open Method features of window object open method channelmode directories dependent fullscreen screenX screenY height left location menubar resizable alwaysLowered alwaysRaised mosgoogle ce
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape