100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC 331 Exams 1 & 2 Combined correctly answered already passed $16.99   Add to cart

Exam (elaborations)

CSC 331 Exams 1 & 2 Combined correctly answered already passed

 0 view  0 purchase
  • Course
  • CSC 331
  • Institution
  • CSC 331

CSC 331 Exams 1 & 2 Combined correctly answered already passed

Preview 2 out of 13  pages

  • November 16, 2024
  • 13
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSC 331
  • CSC 331
avatar-seller
BravelRadon
CSC 331 Exams 1 & 2 Combined
correctly answered already passed

The .class extension on a file means that the file - correct answer ✔✔is produced by the Java compiler
(javac).



Which of the following does not contain a syntax error?

a) System.out.println("Hello world!");

b) System.out.println("Helloworld!");

c) System.out.println(Hello world!);

d) System.out.println('Hello world!'): - correct answer ✔✔a) System.out.println("Hello world!");



All import declarations must be placed - correct answer ✔✔before the class declaration



A(n) ___ enables a program to read data from the user - correct answer ✔✔Scanner



What is the Scanner method for inputting an integer value? - correct answer ✔✔nextInt



What is the value of result after the following Java statements execute (assume all variables are of type
int)?

a = 4; b = 12; c = 37; d = 51;

result = d % a * c + a % b + a; - correct answer ✔✔119



What will be output after the following Java statements have been executed (assume all variables are of
type int)?

a = 4; b = 12; c = 37; d = 51;

if (a < b) {System.out.println("a < b");}

if (a > b) {System.out.println("a > b");}

, if (d <= c) {System.out.println("d <= c");}

if (c != d) {System.out.println("c != d");} - correct answer ✔✔a<b

c != d



What is output by the following Java code segment?

int temp = 180;

while (temp != 80)

{if (temp > 90) {

System.out.print("This porridge is too hot! ");

// cool down

temp = temp - (temp > 150 ? 100 : 20);

}else {

if (temp < 70) {

System.out.print("This porridge is too cold! ");

// warm up

temp = temp + (temp < 50 ? 30 : 20);}

}}

if (temp == 80) {System.out.println("This porridge is just right!");} - correct answer ✔✔This porridge is
too hot! This porridge is just right!



How many times is the body of the loop below executed?

int counter = 1;

while (counter > 20) {

loopcounter = counter - 1;

} - correct answer ✔✔0



The control variable of a counter-controlled loop should be declares as ___ to precent errors - correct
answer ✔✔int

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller BravelRadon. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $16.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75323 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$16.99
  • (0)
  Add to cart