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";
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.