• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 4 pages
Exam (elaborations)

Ap Computer Science A Unit 2 Exam

Document preview thumbnail
Preview 1 out of 4 pages

AP COMPUTER SCIENCE A UNIT 2 EXAM

Content preview

AP COMPUTER SCIENCE A: UNIT 2 EXAM

Consider the following variable declarations.

int a = 5;
int b = 4;
double x = 5;
double y = 4;

Which of the following expressions would evaluate to the number, 1?

1. (int) x / y
2. a / b
3. a % b - Answer -All of them. (1 , 2, and 3)

Consider the following variable declarations.
1. double x = (int) 3.4
2. int y = (int) , 5
3. String z = new String(" ") - Answer -1 and 3

Consider String a below. Which of the following would create a new String with the
value, "ram"?
String a = new String ("Java Program"); - Answer -String b = a.substring(9);

Better code will NOT type in a static number to produce words near the end of the
String and instead, uses length. Which of the following will result in "ram" in a better way
than #2 did? - Answer -String b = a.substring(a.length()-3);

What special type of data is identified it has methods , unlike primitive data? Another
giveaway that this is not primitive data is that variables of this type begin with a capital
letter. - Answer -Objects

Consider the code segment below. What is the result that is printed on the screen?

String six = new String ("Question 6");
int find = six.indexOf("q");
find = find + 2;
System.out.println(find + six.indexOf("t"); - Answer -5

What is the value stored in z by the end of the code segment?
int x = 3;
int y = 6;
double z = x + y / 2; - Answer -6.0

What is the value stored in c by the end of the code segment?

Document information

Uploaded on
November 10, 2025
Number of pages
4
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
GEEKA
3.8
(376)
Sold
2223
Followers
1450
Items
62835
Last sold
1 hour ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions