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)

ITSC 1213 TEST 1 QUESTIONS AND CORRECT ANSWERS

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
23-07-2026
Written in
2025/2026

ITSC 1213 TEST 1 QUESTIONS AND CORRECT ANSWERS

Content preview

ITSC 1213 TEST 1 QUESTIONS AND CORRECT
ANSWERS


A constructor must have which of the following? - Answers - the exact same name as
the class name

After running this code, what will the value of count be?

Hobbit[] myHobbits = new Hobbit[20];
int count = 1;

while (count < 10) {
for (int i = 0; i < myHobbits.length; i+=3) {
myHobbits[i] = new Hobbit("Hobbit #" + count);
count++;
}
} - Answers - 15

Assume that (based on how the random assignment goes), Frodo has the ring and
Bilbo doesn't. What is the output of this program?

public class Hobbit {

private int age;
private String name;

public Hobbit(String n) {
name = n;
}

public void setAge(int x) {
age = x;
}

public int getAge() {
return age;
}

public boolean hasRing() {

if (Math.random() > 0.5) {
return true;

, } else {
return false;
}
}
}

public class Test {
public static void main(String[] args) {

Hobbit bilbo = new Hobbit("Bilbo");
Hobbit frodo = new Hobbit("Frodo");
Hobbit samwise = new Hobbit("Samwise");
Hobbit merry = new Hobbit("Merry");
Hobbit pippin = new Hobbit("Pippin");

bilbo.setAge(110);
frodo.setAge(38);
samwise.setAge(36);
merry.setAge(34);
pippin.setAge(32);


bilbo.setAge(frodo.getAge());
pippin.setAge(samwise.getAge());
frodo.setAge(pippin.getAge());


System.out.println("frod - Answers - frodo's age = 36
bilbo's age = 38
Phew!

Assume the following statement is added to the end of Test:

System.out.println(pippin.getAge() == merry.getAge());

What is the output of this statement?

public class Hobbit {

private int age;
private String name;

public Hobbit(String n) {
name = n;
}

Document information

Uploaded on
July 23, 2026
Number of pages
11
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$14.99
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.
QUEENS Harvard University
View profile
Follow You need to be logged in order to follow users or courses
Sold
228
Member since
4 year
Number of followers
180
Documents
4767
Last sold
4 days ago

4.1

61 reviews

5
35
4
10
3
8
2
3
1
5

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