All AP Computer Science A Resources
Example Questions
Example Question #4 : Program Analysis
Identify a user error that could occur in this program
UserInput ui = new UserInput(); // input from the user
int s = (Integer)ui;
System.out.println(s);
Possible Answers:
The user can never do anything wrong
The parseInt statement is incorrect
There is nothing wrong
The user input could not be an integer
Correct answer:
The user input could not be an integer
Explanation:
The user could input a string and the cast to an (Integer) would cause a runtime exception. If there is a runtime exception, the program will stop and open up vulnerabilities to hackers. Once a hacker knows how to halt a program, they can start input bad data to see a database schema to collect data. One way to fix this would be using a utility method such as parseInt(ui).
All AP Computer Science A Resources
Popular Subjects
LSAT Tutors in Chicago, GMAT Tutors in Phoenix, English Tutors in Denver, English Tutors in Boston, Biology Tutors in Atlanta, LSAT Tutors in Los Angeles, Chemistry Tutors in Dallas Fort Worth, Calculus Tutors in San Francisco-Bay Area, MCAT Tutors in Houston, Spanish Tutors in Dallas Fort Worth
Popular Courses & Classes
SAT Courses & Classes in Denver, MCAT Courses & Classes in San Diego, GRE Courses & Classes in Miami, GMAT Courses & Classes in Washington DC, GRE Courses & Classes in Chicago, GRE Courses & Classes in Denver, Spanish Courses & Classes in Seattle, LSAT Courses & Classes in Atlanta, SAT Courses & Classes in Chicago, LSAT Courses & Classes in Miami
Popular Test Prep
SAT Test Prep in Los Angeles, MCAT Test Prep in Phoenix, SSAT Test Prep in San Francisco-Bay Area, GRE Test Prep in Miami, MCAT Test Prep in Miami, SAT Test Prep in Phoenix, LSAT Test Prep in San Diego, SSAT Test Prep in Atlanta, GMAT Test Prep in Washington DC, LSAT Test Prep in San Francisco-Bay Area
![Learning Tools by Varsity Tutors](https://vt-vtwa-app-assets.varsitytutors.com/assets/problems/og_image_practice_problems-9cd7cd1b01009043c4576617bc620d0d5f9d58294f59b6d6556fd8365f7440cf.jpg)