CSCE 111 Final

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/140

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:53 PM on 4/21/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

141 Terms

1
New cards

True or False: The word import in a Java program is a key word reserved by the language.

True

2
New cards

True or False: A byte can contain either 32 or 64 bits.

False

3
New cards

True or False: According to the Java standard naming convention class names and variables must start with an upper case letter and must contain a number.

False

4
New cards

True or False: Each byte is assigned a unique number known as a bytecode.

False

5
New cards

True or False: In computers, data is stored in a hexadecimal form, which is denoted as 0x00-0x11.

False

6
New cards

True or False: What is the value of b after executing these statements

boolean b;

int x = 10, y = 7, z =10;

if (x>y && y>z) b = true;

if (yy) b = false;

if (xx && z

False

7
New cards

True or False: The Java Virtual Machine is responsible for executing Java Byte Code.

True

8
New cards

True or False: Java runs differently on different CPU architectures.

False

9
New cards

True or False: A declared variable is always visible to the entire method in which it is declared.

False

10
New cards

True or 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

11
New cards

True or False: Logical errors are mistakes that are not caught by the compiler.

True

12
New cards

True or False: When two Strings are compared using the equals method, their cases are ignored.

False

13
New cards

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

True

14
New cards

True or False: In Java, a method call can only be executed once.

False

15
New cards

True or False: Suppose we have the following declarations

int a = 5, b=3;

is (a* (b/a) ==3) true or false?

False

16
New cards

What is the output of the following code fragment?

String x = "Java rules!";

String y = "TAMU!";

if (y.charAt(3) == x.charAt(1))

System.out.println(y.length());

else

System.out.println(x.length());

11

17
New cards

What would be the value of the x after the following statements were executed?

int x = 17;

switch (x){

case 17:

x += 15;

case 18:

x-= 15;

case 20:

x = 10;

break;

default:

x*=3;

}

10

18
New cards

The name of a variable is known as its...

Identifier

19
New cards

Each different type of CPU has its own...

Machine language

20
New cards

Which one of these is a valid comment in Java

\\ this is a comment

21
New cards

A syntax error differs from a runtime error in that...

syntax errors are reported by the compiler

22
New cards

In the Java programming language, an argument is used to...

provide valued to an invoked method

23
New cards

What is the output of the following code segment?

System.out.print*"A\t" + 4 + "\tB");

A 4 B

24
New cards

The import statement...

allows access to classes defines elsewhere

25
New cards

The keyword 'new'...

allocates memory for the object

26
New cards

Where does the interpreter begins execution?

The interpreter executes instructions as they are read.

27
New cards

Primitive data types

byte

short

int

long

float

double

boolean

char

28
New cards

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

29
New cards

What will be the output after the following statements have been executed?

int x = 5, y = 13;

double z;

z = (double)(y/x);

z += y;

z -= x;

System.out.println(z);

10.0

30
New cards

The major components of a typical computer system consist of...

The CPU

Input/Output devices

Main memory

Secondary storage decives

31
New cards

What is wrong with this code?

class TestClass{

public static void main(String [] args){

int x = 0;

double y = 3;

if (x == y) System.out.println("Equal");

if (x

There is nothing wrong

32
New cards

A program is a sequence of instructions stored in..

memory

33
New cards

When a computer is running a program, the CPU is engaged in a process formally known as...

The fetch/decode/execute cycle

34
New cards

Variables are...

symbolic names made up by the programmer that represent locations in the computer's RAM

35
New cards

What will be printed when the following code is executed?

double x = 13579.246;

DecimalFormat formatter = new DecimalFormat("#,##0.0");

System.out.println(formatter.format(x));

13,579.2

36
New cards

RAM is usually...

A volatile type of memory, used only for temporary storage

37
New cards

Key words are...

Words that have a special meaning in the programming language and words that cannot be re-defined by the programmer

38
New cards

A Java program must have one of these...

a main method

39
New cards

What will be printed when the following code segment is executed?

int y = 32;

if (y <= 40)

{

int x = 30;

x += y;

}

System.out.print("x = ");

System.out.print(x);

There will be a compile error.

40
New cards

In Java, ____________ must be declared before they can be used.

variables

41
New cards

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");

The top three teams are

New England Patriots

Greenbay PackersSeattle Seahawks

42
New cards

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

String name = "Hillary Trump";

The memory address where "Hillary Trump" is located

43
New cards

What will be displayed as a result of executing the following code?

int x = 5, y = 14;

x += 30;

if (x > 32) y/= 4;

System.out.println("x = " +x+ ", y = " +y);

x = 35, y = 3

44
New cards

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.prinltn(value2);

System.out.println(value3);

int value3 = 3;

}

}

There will be a compile error.

45
New cards

What does the following code display?

int a = 6;

double b = 16.2;

System.out.printf("%2.3f %4d\n", b, a);

16.200 6

46
New cards

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 == 'I')

(d) if (chr = 'I')

(e) if (chr == o)

c

47
New cards

What is the value of z after the following code has been executed?

int x = 13;

int y = 16, z = 6;

if (y < x);

z += x;

19

48
New cards

What would be the value of bonus after the following statements are executed?

int bonus, sales = 2500;

if (sales > 2000)

bonus = 1000;

if (sales > 500);

bonus = 250;

if (sales > 50)

bonus = 25;

else

bonus = 0;

25

49
New cards

True or False: The private method modifier means the method is available to code outside the class.

False

50
New cards

True or False: The PrintWriter class will append to an already existing file.

False

51
New cards

True or False: A return statement used in a void method terminates the program.

False

52
New cards

True or False: Java provides unary operators that let the programmer increment and decrement variables

True

53
New cards

True or False: A method can take values of expressions as arguments.

True

54
New cards

True or False: A variable's scope is always the entirety of the class in which the variable is declared.

False

55
New cards

True or False: When you use the Scanner class, the class can potentially throw an IOException.

True

56
New cards

True or False: A value-returning code fragment results in an infinite loop.

int i = 100;

while (i != 100){

i--;

}

False

57
New cards

True or False: A class defines how the object created from this class will work.

True

58
New cards

True or False: Local variables are stored in an area of memory called stack.

True

59
New cards

True or False: Since the do-while loop always executes for at least one iteration, it requires its conditions to be true for the first iteration.

False

60
New cards

True or False: In a for statement, the control variable must be incremented by 1 for each iteration.

False

61
New cards

True or False: When the continue statements is encountered in a loop, the execution continues from the beginning of the body of the loop.

False

62
New cards

True or False: An array index can be a double value.

False

63
New cards

What will be printed after the following code is executed?

for (int number = 5; number <= 10; number -=3)

System.out.print(number + ", ");

An infinite series of numbers

64
New cards

Which of the following will open a file named SomeText.txt and allow you to read data from it?

(a) File file = new File ("SomeText.txt);

Scanner inputFile = new Scanner(file);

(b) File file = new File("SomeText.txt");

(c) PrintWriter inputFile = new PrintWriter(SomeText.txt);

(d) Scanner inputFile = new Scanner("SomeText.txt");

(e) File file = new File("SomeText.txt);

Scanner inputFile = new Scanner(System.in);

a

65
New cards

You can use this method to determine whether a file exists.

The File class's exists method

66
New cards

Methods are commonly used to...

break a problem down into small manageable pieces

67
New cards

Which method return type is invalid?

(a) int

(b) double

(c) Scanner)

(d) String

(e) class

e

68
New cards

If method A calls method B, and method B calls method C, and method C calls method A, when the last call to method A finishes, what happens?

control is returned to method C

69
New cards

Which of the following would be a valid method call for the following method?

public static void decideWinner(char c, int num1, double num2)

{

int winner;

winner = num1 * (int)num2;

System.out.println("The winner is " +winner);

}

(a) decideWinner('d', 4.1, 3.0);

(b) decideWinner('a', 4, 2);

(c) decideWinner("c", 9, 2.1);

(d) decideWinner('b', 3.7, 5);

(e) all of the above

b

70
New cards

When an object, such as a String, is passed as an argument, it is...

actually a reference to the object that is passed

71
New cards

A parameter variable's scope...

is the method in which the parameter is declared.

72
New cards

What is the output of the following code?

int a = 2, b = 2;

while (--a > 0 && b++ > 0){

System.out.println(a + " " + b);

1 3

73
New cards

Local variables...

are only meant for use in the method they are declared and lose the values stored in them between calls to the method in which the variable is declared.

74
New cards

Which of the following values can be passed to a method that has an int parameter variable?

(a) int

(b) short

(c) double

(d) A and B

(e) all of the above

d

75
New cards

When you pass an argument to a method...

it initializes the parameter variable in the method definition.

76
New cards

The method header must specify....

The parameters of the method and the data type of the return value.

77
New cards

The phrase divide and conquer is sometimes used to describe...

the process of breaking a problem down into smaller pieces.

78
New cards

The values of local variables...

are lost between calls to the method in which they are declared

79
New cards

Local variables can be initialized with...

constant values

values passed into the method via parameters

the results of an arithmetic operation

80
New cards

How many "USA" are displayed from the following code fragment?

int count = 0;

while (count < 8)

System.out.println("USA");

count ++)

Infinite

81
New cards

Consider the following program:

for (int loop1 = 0; loop1 <= 11; loop1++)

for (int loop2 = 0l loop2 <=11; loop2++)

System.out.println("1");

How many lines of output will be printed?

144

82
New cards

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

methods

83
New cards

For the following code, which statement is not true?

public class Car

{

private String make;

public double price;

private int year;

private String owner;

}

(a) price is available to code that is written outside the Car class.

(b) make is not available to code written outside the Car class.

(c) owner is available to code that is written outside the Car class.

(d) make, price, year, and owner are called data fields of the Car class.

(e) Class Car can have both public and private fields, even though it is declared public

c

84
New cards

What will be the value of sum after the following code is executed?

int sum, left = 5, middle = 1, right = 4;

sum = (left++) * (middle++) / (++right);

1

85
New cards

Each repetition of a loop is known as what?

an iteration

86
New cards

What will be the value of a after the following code is executed?

int a = 3, b = 17;

while (b < 100)

{

a+= b;

b -+a;

}

This is an infinite loop

87
New cards

__________ is the process of inspecting data given to the program by the user and determining if it is reasonable.

Input Validation

88
New cards

How many times will the following for loop be executed?

for (int count = 15; count <= 26; count++)

System.out.println("How many times?");

12

89
New cards

What value is not stored in the array?

int[] array = new int[10];

for (int i = 0, i < array.length; i++)

array[i] = i;

System.out.println(array[4]);

10

90
New cards

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

Sentinel

91
New cards

This type of loop is ideal in situations where the exact number of iterations is known.

for

92
New cards

Given the following statement, which statement will write "AGGIES" to the file DiskFile.txt?

PrintWriter pwtr = new PrintWriter("DiskFile.txt);

(a) System.out.println(diskOut, "AGGIES");

(b) pwtr.println("AGGIES");

(c) DiskFile.println("AGGIES");

(d) PrintWriter.println("AGGIES");

(e) None of the above

b

93
New cards

What will be the values of x and y as result of the following code?

int x =4, y =7;

x += y++;

y = --x + --x;

x *= y--;

x = 171

y = 18

94
New cards

Which of the following are pre-test loops?

(a) while, for, if, do-while

(b) while, do-while

(c) for, do-while

(d) while, for

(e) for, if, while

d

95
New cards

To determine the value of an array during runtime each array has a field associated with it called...

length

96
New cards

True or False: The enhanced for loop can be used to change the elements in an array.

False

97
New cards

True or False: An advantage of ArrayList over arrays is that they can hold different types.

False

98
New cards

True or False: A single copy of a class's static field is shared by all instances of the class.

True

99
New cards

True or False: Instance methods should have the keyword static in their headers.

False

100
New cards

True or False: An array can only hold values of primitive types.

False