Question
How can an exception be thrown manually by a programmer?

Answers

In order to throw an exception in a block of code manually, throw keyword is used. Then this exception is caught and handled in the catch block.
Java
public void topMethod(){
try{
excMethod();
}catch(ManualException e){ }
}
public void excMethod{
String name=null;
if(name == null){
throw (new ManualException("Exception thrown manually ");
}
} 123456789101112
public void topMethod(){try{excMethod();}catch(ManualException e){ }} public void excMethod{String name=null;if(name == null){throw (new ManualException("Exception thrown manually ");}}

    Your Comment




More Software,Java,programmers Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q State the working rule to determine extreme value of the function f(x,y)
  • Q Can i return (twisted) deferreds from signal handlers?
  • Q What does invoke built-in do?
  • Q Illustrate the appendages of prawn.
  • Q What modular programming?
  • Q How to install rpm packages in redhat & centos linux ?
  • Q A person vows to do a thing if his wish is granted by Allah Ta’ala. After sometime when his wish is still unfulfilled can the person cancel the “Nazr” (vow)?
  • Q what are the guidelines to follow to buy a YouTube Channel?
  • Q What is difference between List < ? > and List < Object > in Java
  • Q What is the point of studying English?
  • Q You’re a new addition to the crayon box, what color would you be and why?