100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

AP Computer Science - Chapter 2 Review Questions with Verified Solutions

Rating
-
Sold
-
Pages
32
Grade
A+
Uploaded on
28-08-2024
Written in
2024/2025

AP Computer Science - Chapter 2 Review Questions with Verified Solutions Which of the following data types is used to store a single character in Java? A) `String` B) `int` C) `char` D) `boolean` Answer: C) char What will be the result of the following code snippet? ```java int a = 10; int b = 3; int result = a / b; 2 Sln(result); ``` A) `3.33` B) `3` C) `10` D) `0` Answer: B) 3 How do you declare an `ArrayList` of `Integer` objects in Java? A) `ArrayList<Integer> list = new ArrayList<Integer>();` B) `ArrayList list = new ArrayList<Integer>();` C) `ArrayList<Integer> list = new ArrayList();` D) `ArrayList<Integer> list = new List<Integer>();` Answer: A) ArrayList<Integer> list = new ArrayList<Integer>(); 3 Which method is used to add an element to the end of an `ArrayList`? A) `add()` B) `insert()` C) `append()` D) `push()` Answer: A) add() What does the following code snippet do? ```java String str = "hello";

Show more Read less
Institution
AP Computer Science - Chapter 2
Course
AP Computer Science - Chapter 2











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
AP Computer Science - Chapter 2
Course
AP Computer Science - Chapter 2

Document information

Uploaded on
August 28, 2024
Number of pages
32
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

AP Computer Science - Chapter 2
Review Questions with Verified
Solutions
Which of the following data types is used to store a single character in Java?




A) `String`

B) `int`

C) `char`

D) `boolean`




✔✔ Answer: C) char




What will be the result of the following code snippet?




```java

int a = 10;

int b = 3;

int result = a / b;


1

,System.out.println(result);

```




A) `3.33`

B) `3`

C) `10`

D) `0`




✔✔ Answer: B) 3




How do you declare an `ArrayList` of `Integer` objects in Java?




A) `ArrayList<Integer> list = new ArrayList<Integer>();`

B) `ArrayList list = new ArrayList<Integer>();`

C) `ArrayList<Integer> list = new ArrayList();`

D) `ArrayList<Integer> list = new List<Integer>();`




✔✔ Answer: A) ArrayList<Integer> list = new ArrayList<Integer>();


2

,Which method is used to add an element to the end of an `ArrayList`?




A) `add()`

B) `insert()`

C) `append()`

D) `push()`




✔✔ Answer: A) add()




What does the following code snippet do?




```java

String str = "hello";

System.out.println(str.substring(1, 4));

```




A) `hell`


3

, B) `ell`

C) `he`

D) `hello`




✔✔ Answer: B) ell




Which of the following operators is used to compare two values for equality in Java?




A) `==`

B) `=`

C) `!=`

D) `===`




✔✔ Answer: A) ==




What will be the output of this code?




```java


4

Get to know the seller

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.
BrilliantScores Chamberlain College Of Nursng
View profile
Follow You need to be logged in order to follow users or courses
Sold
2826
Member since
3 year
Number of followers
2233
Documents
16200
Last sold
2 days ago
latest updated documents, correct, verified &amp; graded A study materials

get bundles, documents, test banks, case studies, shadow health's, ATIs, HESIs, study guides, summary, assignments &amp; every kind of study materials.

3.8

774 reviews

5
388
4
117
3
116
2
37
1
116

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

Frequently asked questions