Java ch 1-4

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

In Java, when a character is stored in memory, it is actually the __________ that is stored

Unicode number

The primitive data types only allow a _____ to hold a single value

Variable

Which of the following is a named storage location in the computer's memory

Variable

In Java, _____ must be declared before they can be used

Variables

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

a way to terminate

Which of the following is not a valid Java comment

*/comment two/*

What will be the value of x after the following statements are executed? int x = 75; int y = 60; if (x > y) x = x - y;

15

What is the value of x after the following code has been executed? int x = 75; int y = 90; if (x != y) x += y;

165

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

What will be the value of x after the following statements are executed? int x = 10; for (int y = 5; y < 20; y +=5) x += y;

40

There are ___ bits in a byte

8

What is the value of z after the following statements have been executed? Int x = 4, y = 33; double z; z = (double) (y / x);

8.0

A computer program is

A set of instructions that allow the computer to solve a problem or perform a task

The variable used to keep a running total in a loop is called a(n)

Accumulator

Which of the following is not part of the programming process

All of there are part of the programming process

A loop that executes as long as a particular condition exists is called a(n) __________ loop

Conditional

A loop that repeats a specific number of times is known as a(n) __________ loop.

Count-controlled

Which of the following is not a rule that must be followed when naming identifiers

Identifiers can contain spaces

If a loop does not contain, within itself, a valid way to terminate, it is called a(n) __________ loop

Infinite

An ___ is a software entity that contains data and procedures

Object

A set of programming language statements that perform a specific task is a

Procedure

A ____ is used to write computer programs

Programming language

Byte code instructions are

Read and interpreted by the JVM

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

Relational

Which of the following will format 12.78 to display as 12.8%?

System.out.printf("%.1f%%"", 12.78);

To print "Hello, world" on the monitor, which of the following Java statements should be used

System.out.println("Hello, world");

The __________ loop allows the user to decide on the number of iterations

user controlled loop

What will be the values of x and y as a result of the following code? int x = 25, y = 8;x += y++;

x = 33, y = 9

The variable that controls the number of times a loop iterates is known as a(n)

counter variable

When the break statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration

false

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

for

Each repetition of a loop is known as a(n)

iteration

The switch statement is a

multiple alternative decision structure

If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?

str1.equals(str2)

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

this is an infinite loop

Software refers to

programs

Before entering a loop to compute a running total, the program should first

set the accumulator variable to an initial value, often zero

When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration

true

A flag may have the values

true or false

An expression tested by an if statement must evaluate to

true or false

What does the following code display? double x = 12.3798146; System.out.printf("%.2f\n"", x);

12.38

Which of the following is the not equal operator?

!=

A Java source file must be saved with the extension

.java

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 x after the following code is executed? int x = 10;while (x < 100){ x += 100;}

110

What will be the value of pay after the following statements are executed? int hours = 45; double pay, payRate = 10.00; pay = hours <= 40 ? hours * payRate : 40 * payRate + (hours - 40) *payRate * 1.5;

475.00

What is the result of the following expression? 10 + 5 * 3 - 20

5

A java program must have at least one of the following:

A class definition

Which of the following is a software entity that contains data and procedures

An object

Because Java byte code is the same on all computers, compiled Java programs

Are highly portable

A characteristic of _______ is that only an object's methods are able to directly access and make changes to an object's data

Data hiding

Which of the following would contain the translated Java byte code for a program named Demo

Demo.class

The __________ loop is ideal in situations where you always want the loop to iterate at least once

Do-while

Which of the following statements is invalid

Double r = 2.9X106

Variables of the boolean data type are useful for

Evaluating conditions that are either true or false

Which of the following is a value that is written into the code of a program

Literal

Validating the results of a program is important to

Make sure the program solves the OG problem

The end of a Java statement is indicated by a

Semicolon (;)

A __________ is a value that signals when the end of a list of values has been reached.

Sentinel

Character literals are enclosed in ______ and string literals are enclosed in ________

Single quotes, double quotes

Variables are

Symbolic names made up by the programmer that represent memory locations

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

The code contains an error and will not compile.???????

In the following Java statement, what value is stored in the variable name?

The memory address where "John Doe" is located

An object typically hides its data but allows outside code access to

The methods that operate on the data

Application software refers to

The programs that make the computer useful to the user

What is syntax?

The rules that must be followed when writing a program

Keywords are

Words that have a special meaning in the programming language

What is the value of ans, x, and y after the following statements are executed? int ans = 0, x = 15, y = 25; if ( x >= y) {ans = x + 10;x -=y;} else {ans = y + 10;y += x;}

ans = 35, x = 15, y = 40

If you prematurely terminate an if statement with a semicolon, the compiler will

both (a) and (b)

A block of code is enclosed in a set of

braces, { }

Variables are classified according to their

data type

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

if

To compile a program named First you would use which of the following commands

javac First.java

A runtime error is usually the result of

logical error

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

the statement or block following the else is executed

Which of the following are pre-test loops?

while, for

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

x <= y

Which of the following statements will correctly convert the data type if x is a float and y is a double

x = (float)y;

If x has been declared an int, which of the following statements is invalid

x = 1,000;


Set pelajaran terkait

Psychology Chapter 5 Learning Quiz

View Set

UNIT 5 CH 37 Stephen Nathanson: The Death Penalty as a Symbolic Issue

View Set

Intro to Financial Management & Accounting Systems

View Set

ACCT 340 Bus Law Hemker Exam 4 Final

View Set

Managerial Accounting CHAPTER FOUR

View Set

Criminal Law - CRJ1400 - Chapter 5

View Set

Principles of Marketing Chapter 4 Lab questions

View Set