Computer Programming Final Exam review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Java requires that the boolean expression being tested by an if statement be enclosed in

a set of parentheses

In all but very rare cases, loops must contain, within themselves

a way to terminate

What will be displayed after the following statements are executed? int x = 65; int y = 55; if (x >= y) { int ans = x + y; } System.out.println(ans);

120

What will be the value of x after the following statements are executed

15

What will be displayed after the following statements are executed? int y = 10; if (y == 10) { int x = 30; x += y; System.out.println(x); }

40

Which relational operator is used to test equality in java?

==

A loop that repeats a specific number of times is known as a

Count-controlled

Which of the following statements will create an object from the Random class

Random myNumber = new Random();

__________ operators are used to determine whether a specific relationship exists between two values.

Relational

The boolean expression in an if statement must evaluate to

true or false

To indicate the flow of the program in a flowchart, you use

arrows

The key word new

creates an object in memory

A __________ is a boolean variable that signals when some condition exists in the program

flag

The __________ loop is ideal in situations where the exact number of iterations is known.

for

Which Scanner class method reads a String

nextLine

Step 3 of program development is

none of the above

Of the following, which would be considered the no-argument constructor for the Rectangle class?

public Rectangle()

What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; if (purchase > 1000) discountRate = 0.05; else if (purchase > 750) discountRate = 0.03; else if (purchase > 500) discountRate = 0.01;

0.0

What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; char cust = 'N'; if (purchase > 1000) if (cust == 'Y') discountRate = 0.05; else discountRate = 0.04; else if (purchase > 750) if (cust == 'Y') discountRate = 0.04; else discountRate = 0.03; else discountRate = 0.0;

0.04

How many times will the following do-while loop be executed? int x = 11; do { x += 20; } while (x > 100);

1

What will be the value of bonus after the following statements are executed? int bonus, sales = 10000; if (sales < 5000) bonus = 200; else if (sales < 7500) bonus = 500; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; else bonus = 1250;

1000

What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; y += 20; }

210

What will be the value of x after the following statements are executed? int x = 10; switch (x) { case 10: x += 15; case 12: x -= 5; break; default: x *= 3; }

25

What will be displayed after the following statements are executed? int hours = 30; double pay, payRate = 10.00; pay = hours <= 40 ? hours*payRate : hours*payRate*2.0; System.out.println(pay);

300

How many times will the following do-while loop be executed? int x = 11; do { x += 20; } while (x <= 100);

5

Class objects normally have __________ that perform useful operations on their data, but primitive variables do not

Methods

Which of the following statements correctly creates a Scanner object for keyboard input

Scanner keyboard = new Scanner(System.in);

What will be the value of ans after the following statements are executed? int x = 40; int y = 40; if (x = y) ans = x + 10;

The code contains an error and will not compile

For the following code, which statement is not true? public class Sphere { private double radius; public double x; private double y; private double z; }

The z field is available to code that is written outside the Sphere class

Enclosing a group of statements inside a set of braces creates

a block of statements

What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y = 50; if (x >= y) { ans = x + 10; x -= y; } else { ans = y + 10; y += x; }

ans = 60, x = 0, and y = 50

One or more objects may be created from a

class

A constructor

has the same name as the class

The __________ statement is used to create a decision structure which allows a program to have more than one path of execution

if

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)

if (temp >= 0 && temp <= 100)

Which is the key word used to import a class

import

Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and __________ as instances of the house built from the blueprint

objects

A constructor is a method that

performs initialization and setup operations

In an if-else statement, if the boolean expression is false

the statement or block following the else is executed

Which of the following expressions will determine whether x is less than or equal to y

x<=y


Set pelajaran terkait

REAL ESTATE SALESPERSON EXAM- chapter 2 questions

View Set

Unit 1 - Challenge 2: Web engineering Disciplines and methodologies

View Set

Vocab Lesson 7 Complete the Sentence

View Set

Med Surg I Prep U Chapter 36: Management of Patients With Immune Deficiency Disorders

View Set

Nutrition: concepts and controversies: Chapter 6

View Set