All AP Computer Science A Resources
Example Questions
Example Question #1 : 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
There is nothing wrong
The parseInt statement is incorrect
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 San Francisco-Bay Area, Calculus Tutors in Atlanta, Calculus Tutors in Washington DC, Biology Tutors in San Francisco-Bay Area, ACT Tutors in Los Angeles, Math Tutors in Houston, Math Tutors in Chicago, Physics Tutors in Denver, French Tutors in Dallas Fort Worth, ACT Tutors in Boston
Popular Courses & Classes
SAT Courses & Classes in San Francisco-Bay Area, GRE Courses & Classes in Atlanta, SAT Courses & Classes in Chicago, ISEE Courses & Classes in Seattle, GMAT Courses & Classes in Washington DC, MCAT Courses & Classes in Miami, Spanish Courses & Classes in Atlanta, MCAT Courses & Classes in Houston, LSAT Courses & Classes in Phoenix, SSAT Courses & Classes in San Diego
Popular Test Prep
SSAT Test Prep in Philadelphia, ISEE Test Prep in New York City, SSAT Test Prep in Seattle, ISEE Test Prep in Washington DC, MCAT Test Prep in Seattle, GMAT Test Prep in Seattle, ACT Test Prep in Phoenix, ACT Test Prep in Philadelphia, LSAT Test Prep in Phoenix, GRE Test Prep in Dallas Fort Worth
![Learning Tools by Varsity Tutors](https://vt-vtwa-app-assets.varsitytutors.com/assets/problems/og_image_practice_problems-9cd7cd1b01009043c4576617bc620d0d5f9d58294f59b6d6556fd8365f7440cf.jpg)