All quizes

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

1/80

flashcard set

Earn XP

Description and Tags

Every CS quiz from semester

Last updated 4:59 AM on 5/9/23
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

81 Terms

1
New cards
2
New cards
If method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?
control is returned method
3
New cards
The process of breaking a problem down into smaller pieces is sometimes called __________.
the divide and computer method
4
New cards
Which type of method performs a task and sends a value back to the code that called it?
value returning
5
New cards
When you pass an argument to a method you should be sure that the argument's type is compatible with ________
the parameter variable data type
6
New cards
Methods are commonly used to:
Break a problem down into small manageable pieces
7
New cards
Given the following method, which of these method calls is **correct**?

public static void showProduct (int num1, double num2)

{

   int product;

   product = num1 \* (int)num2;

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

}
showProduct(…)
8
New cards
\
Given the following method header, which of these method calls is **incorrect**?

\
public void displayValue(int x, int y)
displayValue(a,b);// where a is a long and b is an int
9
New cards
\
A __________ type of method performs a task and then terminates.
void
10
New cards
Assume that the following method header is for a method in class A.

public void displayValue(int value)

Assume that the following code segments appear in another method, also in class A. Which contains a **correct** **call** to the displayValue method?
int x = 7;

dsiplayValue(x);
11
New cards
\
A __________ is a part of a method that contains a collection of statements that are performed when the method is executed.
method body
12
New cards
What value will be returned from the following method?

public static int methodA()

{

   double a = 3.5 + 4.5;

   return a;

}
nothing, the code ha san error
13
New cards
\
Which of the following is *not* a part of a method call?
return type
14
New cards
What value will be returned from the following method?

\
public static double methodA()

{

   double a = 3.5 + 4.5;

   return a;

}
8\.0
15
New cards
The lifetime of a method's local variable is __________.
only while the method is executing
16
New cards
\
A parameter variable's scope (accessibility) is confined to __________.
the method in which the parameter is declared
17
New cards
\
Values that are sent into a method are called __________.
arguments
18
New cards
In the following code, System.out.println(num) is an example of __________.

\
double num = 5.4;

System.out.println(num);
a void method
19
New cards
Local variables __________.
are only visible to the method in which they are declared
20
New cards
Given the following method, which of these method calls is **correct**?

\
public static void showProduct (double num1, int num2)

{

   double product;

   product = num1 \* num2;

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

}
showProduct(10.0, 4);
21
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
22
New cards
Character literals are enclosed in \__________ and string literals are enclosed in \__________.
single quotes, double quotes
23
New cards
Which of the following is NOT a rule that must be followed when naming identifiers?
identifiers can contain space
24
New cards
What is the result of the following Java expression? 4 + 3 - 2 * 20
-33
25
New cards
What is the result of the following Java expression? 23 % 3
2
26
New cards
What is the result of the following Java expression? 25 / 10
2
27
New cards
In Java, \__________ must be declared before they can be used.
variables
28
New cards
A Java source file must be saved with the extension
.java
29
New cards
A variable of type boolean data may contain which of the following range of values?
true and false
30
New cards
Which of the following is a value that is written into the code of a program?
a literal
31
New cards
Which of the following files would contain the translated Java byte code for a program named Demo?
demo.class
32
New cards
Which of the following commands would you use to compile a program named First?
javac First.java
33
New cards
Which of the following is a named storage location in the computer's memory?
a variable
34
New cards
Variables are classified according to their
data types
35
New cards
Every Java application program must have
a method named main
36
New cards
If x has been declared a variable of type int, which of the following statements is NOT valid?
x\=2,000;
37
New cards
\
Given the following statement, which of the following expressions would be used to generate a value on a game die?

Random randomNumbers = new Random();
die = randomNumbers.nextInt(6) + 1;
38
New cards
\
Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?
FileWriter fwriter = new FileWriter("MyFile.txt", true); \n PrintWriter outFile = new PrintWriter(fwriter);
39
New cards
Assume that inputFile references a Scanner object that was used to open a file.

Which of the following while loops is the correct way to read data from the file until the end of the file is reached?
while (inputFile.hasNext())
40
New cards
\
Which of the following is the method you can use to determine whether a file exists?
the File class's exists method
41
New cards
Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? \n \n PrintWriter diskOut = new PrintWriter("DiskFile.txt"); \n \n -System.out.println(diskOut, "Calvin"); \n -DiskFile.println("Calvin"); \n -PrintWriter.println("Calvin"); \n -diskOut.println("Calvin");
diskOut.println("Calvin");
42
New cards
\
Given the following statement, which of the following expressions will generate a random number in the range of 1 through 10?

Random randomNumbers = new Random();
myNumber = randomNumbers.nextInt(10) + 1;
43
New cards
\
Which of the following statements opens a file named MyFile.txt and allows you to read data from it?
File file = new File("MyFile.txt"); \n Scanner inputFile = new Scanner(file);
44
New cards
\
When working with the PrintWriter class, which of the following import statements should you have near the top of your program?
import java.io.\*;
45
New cards
Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?
int number = inputFile.readInt();
46
New cards
\
Which of the following statements will create an object from the Random class?
Random myNumber = new Random();
47
New cards
\
A(n) __________ is used as an index to pinpoint a specific element within an array.
subscript
48
New cards
\
What would be the result after the following code is executed?

int\[\] x = {23, 55, 83, 19};

int\[\] y = {36, 78, 12, 24};

x = y;

y = x;
x\[\] = {36, 78, 12, 24} and y\[\] = {36, 78, 12, 24}
49
New cards
What will be the result after the following code is executed?

final int ARRAY_SIZE = 5;

double\[\] x = new double\[ARRAY_SIZE\];

for (int i = 1; i <  ARRAY_SIZE; i++)

{

     x\[i\] = 10.0;

   }
all values in the array except the first will be initialized to 10.0
50
New cards
What will be the value of x\[8\] after the following code is executed?

final int SUB = 12;

int\[\] x = new int\[SUB\];

int y = 100;

for(int i = 0; i < SUB; i++)

{

   x\[i\] = y;

   y += 10;

}
180
51
New cards
15\. What would be the result after the following code is executed?

final int SIZE = 25;

int\[\] ages = new int\[SIZE\];

... // Code that will put values in array

int value = 0;

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

{

   value += ages\[i\];

}
value contains the sum of all values in array ages
52
New cards
For the following code, what would be the value of str\[2\]?

String\[\] str = {"abc", "def", "ghi", "jkl"};
a reference to the string object “ghi”
53
New cards
\
When an ***individual element*** of an array is passed to a method __________.
none are true
54
New cards
\
In memory, an array of String objects __________.
consists of an array of references to String objects
55
New cards
\
Java performs ____________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.
array bounds checking
56
New cards
\
\
Given that String\[\] str has been initialized, to get a copy of str\[0\] with all the characters converted to uppercase, you would use the __________ statement.
str.\[0\].toUpperCase());
57
New cards
\
What would be the result after the following code is executed?

int\[\] x = {23, 55, 83, 19};

int\[\] y = {36, 78, 12, 24};

for(int a = 0; a < x.length; a++)

{

   x\[a\] = y\[a\];

   y\[a\] = x\[a\];

}
`{36, 78, 12, 24}` and `y` will contain the values `{23, 55, 83, 19}`.
58
New cards
\
What will be the results after the following code is executed?

int\[\] ages = new int\[25\];

... // Code that will put values in ages

int value = ages\[0\];

for (int a = 1; a < ages.length; a++)

{

  if (ages\[a\] > value)

    value = ages\[a\];

}
value contains the highest value in ages
59
New cards
The __________ indicates the number of elements the array can hold
array’s size
60
New cards
What will be the results after the following code is executed?

int\[\] x = { 55, 33, 88, 22, 99, 11, 44, 66, 77 };

int a = 10;

if(x\[2\] > x\[5\])

   a = 5;

else

   a = 8;
a = 5
61
New cards
\
An array’s subscripts always starts with __________.
0
62
New cards
What would be the result of executing the following code?

int\[\] x = {0, 1, 2, 3, 4, 5};
An array of 6 values ranging from 0 through 5 and referenced by the variable x will be created.
63
New cards
\
What would be the result after the following code is executed?

int\[\] numbers = {40, 3, 5, 7, 8, 12, 10};

int value = numbers\[0\];

for (int i = 1; i < numbers.length; i++)

{

     if (numbers\[i\] < value)

          value = numbers\[i\];

}
The value variable will contain the lowest value in the numbers array.
64
New cards
\
When an array's ***reference variable*** is passed to a method __________.
all of these are true
65
New cards
If final int SIZE = 15 and int\[\] x = new int\[SIZE\], what would be the range of subscript values that could be used with x\[\]?
0 through 14
66
New cards
Each array in Java has a public field named __________ that contains the number of elements in the array.
length
67
New cards
The CPU __________.
 job is to fetch instructions, follow the instructions, and produce some resulting data. 
68
New cards
Input devices are
The device that collects the data and sends it to the computer

* keyboard, scanner, mouse, digital camera
69
New cards
Output devices are
The data is sent to an output device, which formats and presents it.

* monitors and printers
70
New cards
\
Which of the following will compile a program called ReadIt?
\
javac ReadIt.java
71
New cards
\
Byte code instructions are
\
read and interpreted by the JVM
72
New cards
Variables are:
symbolic names made up by the programmer that represents locations in the computer's RAM
73
New cards
A computer program is:
a set of instructions that enable the computer to solve a problem or perform a task
74
New cards
Syntax is:
rules that must be followed when writing a program
75
New cards
______ refers to the physical components that a computer is made of.
hardware
76
New cards
RAM is
a volatile type of memory, used only for temporary storage.
77
New cards
Because Java byte code is the same on all computers, compiled Java programs
are highly portable
78
New cards
Key words are
These are words that have a special meaning in the programming language.
79
New cards
\
A cross between human language and a programming language is called
pseudocode
80
New cards
Which of the following is not one of the major components of a typical computer system?

a. The CPU \n b. Input/ output devices \n c. Main memory \n d. Secondary storage devices \n e. All of these
All of these
81
New cards
Which of the following is not part of the programming process?
All these are parts of the programming process.

Explore top notes

note
OZV casus 7
Updated 432d ago
0.0(0)
note
Chapter 10: Factor Markets
Updated 1066d ago
0.0(0)
note
AP Government Units 1 & 2
Updated 396d ago
0.0(0)
note
AP Microeconomics Formula Sheet
Updated 485d ago
0.0(0)
note
Diseases: Cause and Control
Updated 1085d ago
0.0(0)
note
4.3 Cycles of Matter >
Updated 419d ago
0.0(0)
note
AP Calculus BC Ultimate Guide
Updated 1072d ago
0.0(0)
note
OZV casus 7
Updated 432d ago
0.0(0)
note
Chapter 10: Factor Markets
Updated 1066d ago
0.0(0)
note
AP Government Units 1 & 2
Updated 396d ago
0.0(0)
note
AP Microeconomics Formula Sheet
Updated 485d ago
0.0(0)
note
Diseases: Cause and Control
Updated 1085d ago
0.0(0)
note
4.3 Cycles of Matter >
Updated 419d ago
0.0(0)
note
AP Calculus BC Ultimate Guide
Updated 1072d ago
0.0(0)

Explore top flashcards

flashcards
Lesson 1
20
Updated 729d ago
0.0(0)
flashcards
AP Gov Terms
114
Updated 96d ago
0.0(0)
flashcards
Cells-Important Vocab
49
Updated 469d ago
0.0(0)
flashcards
GLW #2
20
Updated 185d ago
0.0(0)
flashcards
Personality
54
Updated 1127d ago
0.0(0)
flashcards
Lesson 1
20
Updated 729d ago
0.0(0)
flashcards
AP Gov Terms
114
Updated 96d ago
0.0(0)
flashcards
Cells-Important Vocab
49
Updated 469d ago
0.0(0)
flashcards
GLW #2
20
Updated 185d ago
0.0(0)
flashcards
Personality
54
Updated 1127d ago
0.0(0)