Complete the code in the ExTestDrive.java file by replacing the commented-out bl
ID: 3643569 • Letter: C
Question
Complete the code in the ExTestDrive.java file by replacing the commented-out blank lines withsome or all of the code snippets at the top of the file. Your code should produce the following output
when run:
input: yes" output: thaws
input: no" output: throws
// Snippet pool
//
// System.out.print("a");
// System.out.print("o");
// System.out.print("r");
// System.out.print("t");
// System.out.println("ws");
// doRisky(test);
// throw new MyEx();
// yes.equals(t)
//
class MyEx extends Exception { }
public class ExTestDrive {
public static void main (String [] args) {
String test = (new Scanner(System.in)).next();
try {
// ___________________
// ___________________
// ___________________
}
catch (MyEx e) { // ______________________ }
// _____________________
}
static void doRisky(String t) throws MyEx {
System.out.print("h");
if (//______________________) //___________________
// ____________________
}
}
Explanation / Answer
please rate
class MyEx extends Exception { }
public class ExTestDrive {
public static void main (String [] args) {
String test = (new Scanner(System.in)).next();
try {
System.out.print("t");
doRisky(test);
System.out.print("o");
}
catch (MyEx e) {System.out.print("a"); }
System.out.println("ws");
}
static void doRisky(String t) throws MyEx {
System.out.print("h");
if (yes.equals(t)) throw new MyEx();
System.out.print("o");
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.