Can you give me the solution to this question Book Objects f

Can you give me the solution to this question.

Book: Objects first with Java 6th edition.

You are developing code and you want to ensure that you include proper error handling. Create a try/catch block that includes assigning a variable tester to the value of 1 inside the try code block. If an error occurs, then the value of tester should be 2. In either case, include a section of code that will always assign the variable validate to a value of “here”. You should ensure that all code is included within the code construct of the try/catch block.

Solution

TryCatchTest.java


public class TryCatchTest {

  
   public static void main(String[] args) {
       int tester;
       String validate;
       try{
           tester = 1;
           validate = \"here\";
       }
       catch(Exception e){
           tester = 2;
           validate = \"here\";
       }

   }

}

Can you give me the solution to this question. Book: Objects first with Java 6th edition. You are developing code and you want to ensure that you include proper

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site