Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 1331 Exam 1 with accurate detailed solutions

Rating
-
Sold
-
Pages
8
Grade
A+
Uploaded on
13-08-2025
Written in
2025/2026

CS 1331 Exam 1 with accurate detailed solutions

Institution
CS 1331
Course
CS 1331

Content preview

CS 1331 Exam 1 with accurate detailed|!! |!! |!! |!! |!! |!! |!!




solutions


Array - correct answer✔✔Linear, homogenous set of data where you can
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




access each element by an increasing index starting at 0
|!! |!! |!! |!! |!! |!! |!! |!! |!!




What does it mean when we say an array is "homogenous"? - correct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




answer✔✔The array is of a specific type set upon its declaration, i.e. you |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




can't put doubles in a String[] array
|!! |!! |!! |!! |!! |!!




How would you declare an array of integers named "a"? (no specified
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




length or contents) - correct answer✔✔int[] a;
|!! |!! |!! |!! |!! |!!




How would you declare an array of length 10 with integers inside named
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




"a"? - correct answer✔✔int[] a = new int[10]
|!! |!! |!! |!! |!! |!! |!!




What two ways could you declare an array of integers 1-10 increasing by
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




1 named "a"? - correct answer✔✔1) int[] a = {1,2,3,4,5,6,7,8,9,10}
|!! |!! |!! |!! |!! |!! |!! |!! |!!




or with a for loop
|!! |!! |!! |!!




If you declare an array as "int[] a;", what do you have to re-do when you
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




instantiate it? - correct answer✔✔Restate the type: |!! |!! |!! |!! |!! |!!




"a = new int[] {2,4,6}"
|!! |!! |!! |!!




How would you access the 1st element of array "a"? - correct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




answer✔✔a[0];



How do you access the length of array "a"? - correct answer✔✔a.length
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!

, Is accessing the length of an array a method? Why or why not? - correct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




answer✔✔No! It's a public int part of the array class, hence NO |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




parenthesis



What is an array? - correct answer✔✔An object
|!! |!! |!! |!! |!! |!! |!!




For array "a" is a[a.length] a valid way to access an element? - correct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




answer✔✔No! The max index == (a.length - 1) |!! |!! |!! |!! |!! |!! |!!




When you see a problem with an array, what should you use? - correct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




answer✔✔A for loop |!! |!!




What does it mean when we say an array is static? - correct answer✔✔You
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




can't resize them! You would have to make a new array of bigger size &
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




copy everything. |!!




What is the syntax for a while loop? - correct answer✔✔while
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




(someCondition) { |!!




|!! //things that can change someCondition
|!! |!! |!! |!!




}



What is the most common mistake when implementing while loops? -
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




correct answer✔✔Creating an infinite loop
|!! |!! |!! |!!




What is the syntax for a do while loop? - correct answer✔✔do {
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!




} while (someCondition);
|!! |!!

Written for

Institution
CS 1331
Course
CS 1331

Document information

Uploaded on
August 13, 2025
Number of pages
8
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

€12,67
Get access to the full document:

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

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.
Ruiz Liberty University
Follow You need to be logged in order to follow users or courses
Sold
102
Member since
1 year
Number of followers
1
Documents
14000
Last sold
1 week ago
Top-Quality Study Materials for Success – Ace Your Exams with Expert Resources!

Access high-quality study materials to help you excel in your exams. Get notes, summaries, and guides tailored to your courses!

3,2

15 reviews

5
4
4
4
3
2
2
1
1
4

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