Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you give me the solution to this question. Book: Objects first with Java 6th

ID: 3793157 • Letter: C

Question

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.

Explanation / Answer

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";
       }

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote