100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC 1350 Exam #2 Practice Questions and Answers $13.49   Add to cart

Exam (elaborations)

CSC 1350 Exam #2 Practice Questions and Answers

 1 view  0 purchase
  • Course
  • Prep Tests
  • Institution
  • Prep Tests

CSC 1350 Exam #2 Practice Questions and Answers What are the two parts of an if statement? a) An increment and a return value b) An increment and a body c) A check and an increment d) A condition and a body - ANSWER-d) A condition and a body Which of the following statements is true about th...

[Show more]

Preview 4 out of 57  pages

  • November 10, 2024
  • 57
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Prep Tests
  • Prep Tests
avatar-seller
OliviaWest
Copyright © OLIVIAWEST 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED




CSC 1350 Exam #2 Practice Questions

and Answers


What are the two parts of an if statement?


a) An increment and a return value


b) An increment and a body


c) A check and an increment


d) A condition and a body - ANSWER✔✔-d) A condition and a body


Which of the following statements is true about the if statement?




a) The if and else blocks should always be included within curly braces


b) The else block is optional


c) The if statement can have only one condition that evaluates to an integer value


d) The if block is optional - ANSWER✔✔-b) The else blocks is optional


The following code snippet contains an error. What is the error?


if (cost > 100); {


cost = cost -10;


}

Copyright ©Stuvia International BV 2010-2024 Page 1/57

, Copyright © OLIVIAWEST 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


System.out.println("Discount cost: " + cost);


a) Logical error: use of an uninitialized variable


b) Logical error: if statement has do-nothing statement after if condition


c) Syntax error (won't compile)


d) Logical error: assignment statement does not show equality - ANSWER✔✔-b) Logical error: if

statement has do-nothing statement after if condition


What is the output of the following code snippet?


int num = 100;


if (num > 100); {


num = num - 10;


}


System.out.println(num);


a) 100


b) 101


c) 90


d) 99 - ANSWER✔✔-c) 90


The operator !> stands for ____________________.


a) Not greater than


b) This is not an operator in Java.

Copyright ©Stuvia International BV 2010-2024 Page 2/57

, Copyright © OLIVIAWEST 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


c) Not less than


d) Not equal to - ANSWER✔✔-b) This is not an operator in Java.


What is the output of the following code snippet?


int x = 50;


if (x > 100) {


x++;


}


else {


x--;


}


System.out.println(x);


a) 50


b) 51


c) 49


d) 52 - ANSWER✔✔-c) 49


Assuming that the user enters 60 as the input, what is the output after running the following code

snippet?


int num = 0;


Scanner in = new Scanner(System.in);

Copyright ©Stuvia International BV 2010-2024 Page 3/57

, Copyright © OLIVIAWEST 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


System.out.print("Enter a number: ");


num = in.nextInt();


if (num < 10) {


System.out.println("Too small!");


}


else if (num < 50) {


System.out.println("Intermediate!");


}


else if (num < 100) {


System.out.println("High!");


}


else {


System.out.println("Too high!");


}


a) Too high!


b) Intermediate!


c) High!


d) Too small! - ANSWER✔✔-c) High!


What is the output after running the following code snippet?

Copyright ©Stuvia International BV 2010-2024 Page 4/57

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 OliviaWest. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80364 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
$13.49
  • (0)
  Add to cart