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
Document preview thumbnail
Preview 3 out of 21 pages
Exam (elaborations)

CodeHs Midterm EXAM QUESTIONS WITH ANSWERS

Document preview thumbnail
Preview 3 out of 21 pages

CodeHs Midterm EXAM QUESTIONS WITH ANSWERS

Content preview

CodeHs Midterm EXAM |\ |\ |\




QUESTIONS WITH ANSWERS |\ |\




What is the output of this program?
|\ |\ |\ |\ |\ |\




int sum = 1;
|\ |\ |\ |\




System.out.println("Welcome to the adding machine!"); |\ |\ |\ |\ |\




while(sum < 10) |\ |\ |\




{ |\




|\ sum += sum;
|\ |\ |\




|\ System.out.println(sum); |\




} - CORRECT ANSWERS ✔✔Welcome to the adding
|\ |\ |\ |\ |\ |\ |\ |\



machine! {Unit 2} |\ |\




2
4
8
16


What is the output of this for loop?
|\ |\ |\ |\ |\ |\ |\




for(int i = 0; i < 100; i += 2)
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\




{ |\




|\ System.out.println(i); |\

,} - CORRECT ANSWERS ✔✔The even numbers from 0 to
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



98, inclusive {Unit 2}
|\ |\ |\




What is the proper syntax to initialize a double called
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



temperature to have the value 70.4? - CORRECT |\ |\ |\ |\ |\ |\ |\ |\



ANSWERS ✔✔double temperature = 70.4; {Unit 2} |\ |\ |\ |\ |\ |\




Which of the following is not a primitive type? - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



ANSWERS ✔✔String {Unit 2} |\ |\ |\




What in this code segment could potentially cause a bug
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



in our program?
|\ |\




String myString = readLine("What is your name?");
|\ |\ |\ |\ |\ |\ |\




if (myString == "Karel")
|\ |\ |\ |\




{ |\




|\ System.out.println("Hi Karel!"); |\ |\




} |\




else |\




{ |\




|\ System.out.println("You're not Karel!"); |\ |\ |\




} - CORRECT ANSWERS ✔✔Comparing Strings with ==
|\ |\ |\ |\ |\ |\ |\ |\



instead of the .equals method. {Unit 2} |\ |\ |\ |\ |\ |\

, Which of these is not a logical operator? - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\



ANSWERS ✔✔++ {Unit 2} |\ |\ |\




What is the output of this for loop?
|\ |\ |\ |\ |\ |\ |\




for(int i = 10; i > 2; i -= 3) |\ |\ |\ |\ |\ |\ |\ |\ |\ |\




{ |\




|\ System.out.println(i); |\




} - CORRECT ANSWERS ✔✔10
|\ |\ |\ |\




7
4
{Unit 2} |\




What will the values of x and y be after this code segment
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\



runs?
|\




int x = 100; int y = 100; if (x <= 100)
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\




{ |\




|\ if (y > 100)
|\ |\ |\




|\ { |\




|\ x = 200;
|\ |\ |\




|\ } |\




|\ else |\




|\ {

Document information

Uploaded on
March 20, 2026
Number of pages
21
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
£16.98

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.
EXAMSTUDYPLUG
4.5
(242)
Sold
383
Followers
108
Items
20774
Last sold
17 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed 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