CSCE Exam I

¡Supera tus tareas y exámenes ahora con Quizwiz!

In nested if statements, if the inner if statement evaluates to false, the outer if is automatically false.

False

Java runs differently on different CPU architectures.

False

Methods can only be executed once.

False

Once the source code is compiled, it cannot be changed.

False

Suppose we have the following declarations: int i = 4, j = 1; The expression, (i *(j / i) ) == 1, evaluates True or False?

False

The == operator is a more forceful way of saying =, as it allow for operands of different types.

False

The following statement is valid: double xyz = 2,132.54;

False

The type char can hold both single characters or a reference to a string.

False

What is the value of b after executing these statements? boolean b = false; int x = 8, y = 2, z = 1; if (x > y && y > z) b = true; if (y < z || x > y) b = false; if (x < z || y > x && z < x) b = true;

False

Because the || operator performs short-circuit evaluation, your boolean expression will generally be evaluated faster if the subexpression that is most likely to be true is on the left.

True

Logical errors are mistakes that are not caught by the compiler.

True

System.out.print, the nextInt in the Scanner class and main are all "methods".

True

The Java Virtual Machine is responsible for executing Java byte code.

True

The following is valid: final double x = 2.4;

True

When two Strings are compared using the equals method, their cases are also tested.

True

In the Java programming language, an argument is used to ________________. a. provide values to an invoked method b. override the object's default method definition c. define constants in any given program d. perform mathematical tasks (especially algebraic) in Java e. let the Java compiler know the purpose of the method

a

The import statement : a. allows programs to access classes that are already defined elsewhere b. retrieves user input c. copies text, verbatim, from a file d. is needed if the class to be imported is in the same package e. none of the above

a

Variables are: a. Symbolic names made up by the programmer that represents locations in the computer's RAM b. Reserved words c. Symbolic names made up by the programmer whose values cannot be changed d. Operators that perform operations on one or more operands e. None of the above

a

When a computer is running a program, the CPU is engaged in a process formally known as: a. The fetch/decode/execute cycle b. The decrypt/validate/commit cycle c. Low-level machine mode d. Parallax data execution e. Decision selection

a

32. What is the output of the following code fragment? String x = "Howdy Aggies!"; String y = "Gig em!"; if (y.charAt(2) == x.charAt(7)) { System.out.println(y.length()); else System.out.println(x.length()); a. 6 b. 7 c. 9 d. 12 e. 13

b

33. What would be the value of x after the following statements were executed? int x = 17; switch (x) { case 17: x += 15; case 18: x -= 5; case 20: x = 10; break; default: x *= 3; } a. 12 b. 10 c. 27 d. 51 e. 32

b

In the following Java statement what value is stored in the variable name? String name = "James Bond"; a. James Bond b. The memory address where "James Bond" is located c. The word name d. A sequence of bits representing the ascii character values of "James Bond" e. C and D

b

What is the output of the following code segment? System.out.print("X\t" + 6 + "\tY"); a. X6Y b. X 6 Y c. X 6Y d. X X X X X X Y e. Invalid statement

b

When the + operator is used with strings, it is known as the: a. Assignment operator b. String concatenation operator c. Addition operator d. Combined assignment operator e. Print operator

b

Where does the interpreter begin execution? a. The first class b. The main method c. The first method that is public d. The first method listed in the class e. None of the above

b

If the following Java statements are executed, what will be displayed? System.out.println("The top three teams are\n\n"); System.out.print("New England Patriots\n"); System.out.print("Greenbay Packers"); System.out.println("Seattle Seahawks"); a. The top three teams are New England Patriots Greenbay Packers Seattle Seahawks b. The top three teams are New England Patriots\ nGreenbay Packers Seattle Seahawks c. The top three teams are New England Patriots Greenbay PackersSeattle Seahawks d. The top three teams are\n New England Patriots\nGreenbay PackersSeattle Seahawks e. There is an error in the code

c

The int data type may contain values in the following range of values a. true or false b. -128 to + 127 c. - 2,147,483,648 to +2,147,483,647 d. - 32,768 to +32,767 e. None of the above

c

What would be the value of bonus after the following statements are executed? int bonus, sales = 500; if (sales > 400) bonus = 100; if (sales > 250) bonus = 50; if (sales > 50) bonus = 25; else bonus = 0; a. 100 b. 50 c. 25 d. 0 e. None of the above

c

Which of the following is valid? a. short x; int y; double z; x = y = z = 3; b. String y; char z; z = 'a'; y = z; c. float w; double v; w = 1.0f; v = w; d. float v; int y; v = 5.0; y = v;

c

A Java program must have one of these: a. Variable b. Comment c. System.out.println(); statement d. Main method e. Scanner definition

d

If chr is a character variable, which of the following if statements is written correctly? a. if (chr = "h") b. if (chr == "e") c. if (chr = 'l') d. if (chr == 'l') e. if (chr == o)

d

RAM is usually: a. Secondary storage b. An input/output device c. A static type of memory, used for permanent storage d. A volatile type of memory, used only for temporary storage e. A type of memory only used to store random values

d

The keyword 'new': a. starts a new program b. clears the value from a variable c. generates a random integer d. allocates memory for the object e. none of the above

d

The name of a variable is known as its a. Constant b. Data type c. Object d. Identifier e. Method

d

What is the value of a? double a = 25 / 4 + 4 * 10 % 3; a. 10.25 b. 0.5 c. 3.5 d. 7.0 e. 1.25

d

What is the value of ans after the following code has been executed? int a = 27; int b = 10, ans = 53; if (a < b); ans += b; a. 10 b. 27 c. 53 d. 63 e. 90

d

What will be printed when the following code is executed? double x = 98765.456; DecimalFormat formatter = new DecimalFormat("#,##0.0"); System.out.println(formatter.format(x)); a. 98765.4 b. 98760.0 c. 98,765.4 d. 98,765.5 e. There is an error in how DecimalFormat is used

d

What will be the output after the following statements have been executed? int x = 3, y = 17; double z; z = (double) (y / x); System.out.print(z); a. 5.66666667 b. 5.67 c. 5 d. 5.0 e. Code will cause an error

d

7. In an if/else statement, if the boolean expression is false, a. the first statement or block is executed b. all statements or blocks are executed c. no statements or blocks are executed d. the else statement block is executed first, then followed by the if block e. the statement or block following the else is executed

e

A program is a sequence of instructions stored in: a. The CPU b. The motherboard c. Software d. Firmware e. Memory

e

Each different type of CPU has its own: a. Syntax b. Firmware c. Software d. Operating System e. Machine language

e

In Java, ___________ must be declared before they can be used. a. Memory blocks b. Literals c. Key words d. Comments e. None of the above

e

The major components of a typical computer system consist of: a. The CPU b. Input/output devices c. Main memory d. Secondary storage devices e. All of the above

e

What does the following code display? int f = 9; double g = 12.1; System.out.printf("%d %f\n", f, g); a. %d %f\n b. %d %f c. %9 %12.1\n d. 9 12 e. 9 12.1000

e

What is wrong with this code? class TestClass{ public static void main(String [] args){ int x = 99; double y = 11; if (x == y) System.out.println("Equal"); if (x < y) System.out.println(x + " is less"); } } a. The System.out.println statements should be within braces b. The variable y should be declared as 16.0 c. In the print statement, x should be in quotes d. Cannot compare x (int) with y (double) e. There is nothing wrong

e

What will be displayed as a result of executing the following code? int x = 8, y = 20; x += 32; if ( x > 32) y /= 4; System.out.println("x = " + x + ", y = " + y); a. x = 8, y = 20 b. x = 32, y = 4 c. x = 32, y = 20 d. x = 40, y = 4 e. x = 40, y = 5

e

What will be displayed as a result of executing the following code? public class Test { public static void main(String[] args) { int value1 = 15; System.out.println(value1); int value2 = 10; System.out.println(value2); System.out.println(value3); int value3 = 3; } } a. 15 10 3 b. 15103 c. 15 10 3 d. value1 value2 value3 e. Nothing, there is a compile error

e

What will be printed when the following code segment is executed? int y = 10; if ( y <= 10) { int x = 30; x += y; } System.out.print("x = "); System.out.print(x); a. x = 40 b. x = 30 c. x = 20 d. x = 10 e. Nothing, there will be a compile error

e

What will be the values 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 { if (x < y){ ans = y + 10; } y += x; } a. ans = 0, x = 15, y = 25 b. ans = 25, x = -10, y = 25 c. ans = 25, x = 15, y = 40 d. ans = 35, x = 25, y = 40 e. None of the above

e

Which one of these is a valid comment in Java? a. <% This is a comment %> b. \\This is a comment c. COMMENT: This is a comment d. / This is a comment ** e. None of the above are valid

e


Conjuntos de estudio relacionados

Mastering Math Facts Multiplication Set Q (5x8, 8x5, 4x8, 8x4)

View Set

Commonly Missed Questions on the STAAR Released Test

View Set

MAT 120 Section 9.3 Measures of Regression

View Set

homework for econ exam 1, MICRO ECONOMICS, Chapter 2 (unit 1- obj. 10), Econ 1000 Chapter 3, 2.1-2.4, ECON Chapter 2 Homework, ECN101 Chapter 5 Key Terms, Econ 102 Exam, ECON102 CH. 4, 2.4 Gains from Trade, Microeconomics ch3, ECON E 201 Assignment 3...

View Set

RCA 9.6 Practice Quiz Questions (Flash Cards)

View Set