Oracle
1Z0-808 · Question #31
1Z0-808 Question #31: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #31. The question stem and answer options stay visible for context.
Java Basics
Question
public class App {
String myStr = "7007";
public void doStuff(String str) {
int myNum = 0;
try {
String myStr = str;
myNum = Integer.parseInt(myStr);
} catch (NumberFormatException ne) {
System.err.println("Error");
}
System.out.println(
"myStr: " + myStr + ", myNum: " + myNum);
}
public static void main(String[] args) {
App obj = new App();
obj.doStuff("9009");
}
}
What is the result?
Options
- AmyStr: 9009, myNum: 9009
- BmyStr: 7007, myNum: 7007
- CmyStr: 7007, myNum: 9009
- DCompilation falls
Unlock 1Z0-808 to see the answer
You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#Variable shadowing#Variable scope#try-catch blocks#Scope resolution