SlideShare a Scribd company logo
All based on Zybooks = AP Java with zylabs
Please answer all questions - no explanation of answers needed
QUESTION 1
char[][] table = new char[10][5];
How many rows are in the array seen in the accompanying figure?
0
5
10
15
QUESTION 2
The standard output object in Java is ____.
output
System.out
Sys.out
System.in
QUESTION 3
The length of the string "first java program" is:
16
18
19
20
1 points
QUESTION 4
The loop condition of a while loop is reevaluated before every iteration of the loop.
True
False
1 points
QUESTION 5
If str1 is “Hello” and str2 is “Hi”, which of the following could not be a result of
str1.compareTo(str2);?
-9
-5
-1
1
1 points
QUESTION 6
Both System.out.println and System.out.print can be used to output a string on the standard
output device.
True
False
1 points
QUESTION 7
In a method call statement, when passing an array as an actual parameter, you use only its name.
True
False
1 points
QUESTION 8
Which of the following is true about a while loop?
The body of the loop is executed at least once.
The logical expression controlling the loop is evaluated before the loop is entered and after the
loop exists.
The body of the loop may not execute at all.
It is a post-test loop
1 points
QUESTION 9
int x, y;
if (x < 4)
y = 2;
else if (x > 4)
{
if (x > 7)
y = 4;
else
y = 6;
}
else
y = 8;
Based on the code above, what is the value of y if x = 9?
2
4
6
8
1 points
QUESTION 10
The array index can be any nonnegative integer less than the array size.
True
False
1 points
QUESTION 11
When a program executes, the first statement to execute is always the first statement in the main
method.
True
False
1 points
QUESTION 12
Java stores two-dimensional arrays in a row order form in computer memory.
True
False
1 points
QUESTION 13
The statement dataType[][][] arrayName; would declare a two-dimensional array.
True
False
1 points
QUESTION 14
All the methods defined in a class must have different names.
True
False
1 points
QUESTION 15
Which of the following is NOT a reserved word in Java?
double
throws
static
num
1 points
QUESTION 16
Given the declaration
int[] list = new int[50];
the statement
System.out.println(list[0] + "..." + list[49]);
outputs all 50 components of the array list.
True
False
1 points
QUESTION 17
In the case of an infinite while loop, the while expression (that is, the loop condition) is always
true.
True
False
1 points
QUESTION 18
Consider the following program.
public class CircleArea
{
static Scanner console = new Scanner(System.in);
static final double PI = 3.14;
public static void main(String[]args)
{
doubler;
double area;
r = console.nextDouble();
area = PI * r * r;
System.out.println("Area = " + area);
}
}
To successfully compile this program, which of the following import statement is required?
import java.io.Scanner;
import java.util.Scanner;
import java.lang.Scanner;
No import statement is required
1 points
QUESTION 19
An identifier can be any sequence of characters and integers.
True
False
1 points
QUESTION 20
A single array can hold elements of many different data types.
True
False
1 points
QUESTION 21
Consider the following program.
// Insertion Point 1
public class CircleArea
{
// Insertion Point 2
static final float PI = 3.14
public static void main(String[]args)
{
//Insertion Point 3
float r = 2.0;
float area;
area = PI * r * r;
System.out.println("Area = " + area);
}
// Insertion Point 4
}
In the above code, where do the import statements belong?
Insertion Point 1
Insertion Point 2
Insertion Point 3
Insertion Point 4
1 points
QUESTION 22
Suppose that x is an int variable. Which of the following expressions always evaluates to false?
(x > 0) || (x <= 0)
(x > 0) || (x == 0)
(x > 0) && ( x <= 0)
(x >= 0) && (x == 0)
1 points
QUESTION 23
What is the value of alpha[4] after the following code executes?
int[] alpha = new int[5];
for (int j = 0; j < 5; j++)
alpha[j] = 2 * j - 1;
one
three
five
seven
1 points
QUESTION 24
If a = 4; and b = 3;, then after the statement a = b; executes, the value of b is 4 and the value of a
is 3.
True
False
1 points
QUESTION 25
The expression !(x <= 0) is true only if x is a positive number.
True
False
1 points
QUESTION 26
In a return method, the last line of the method must be a return statement.
True
False
1 points
QUESTION 27
The expression (int)8.7 evaluates to ____.
8
8.0
9.0
9
1 points
QUESTION 28
A loop is a control structure that causes certain statements to be executed over and over until
certain conditions are met.
True
False
1 points
QUESTION 29
What is stored in alpha after the following code executes?
int[] alpha = new int[5];
for (int j = 0; j < 5; j++)
{
alpha[j] = 2 * j;
if (j % 2 == 1)
alpha[j - 1] = alpha[j] + j;
}
alpha = {0, 2, 4, 6, 8}
alpha = {3, 2, 9, 6, 8}
alpha = {0, 3, 4, 7, 8}
alpha = {0, 2, 9, 6, 8}
1 points
QUESTION 30
Suppose that x and y are int variables and x = 7 and y = 8. After the statement: x = x * y - 2;
executes, the value of x is ____.
42
54
56
58
1 points
QUESTION 31
A counter-controlled loop should be used when the programmer knows the exact number of loop
iterations are needed.
True
False
1 points
QUESTION 32
In Java, a period is used to terminate a statement.
True
False
1 points
QUESTION 33
In Java, return is a reserved word.
True
False
1 points
QUESTION 34
When an array reference is passed to a method, the method can modify the elements of the array
object.
True
False
1 points
QUESTION 35
A local identifier is an identifier that is declared within a method or block and that is visible only
within that method or block.
True
False
1 points
QUESTION 36
An expression such as str.length(); is an example of a(n) ____.
system call
object call
class
method call
1 points
QUESTION 37
Suppose str1 and str2 are String variables. The expression (str1 == str2) determines whether str1
and str2 reference the same String object.
True
False
1 points
QUESTION 38
Just like the nesting of loops, Java allows the nesting of methods.
True
False
1 points
QUESTION 39
Suppose console is a Scanner object initialized with the standard input device. The expression
console.nextInt(); is used to read one int value and the expression console.nextDouble(); is used
to read two int values.
True
False
1 points
QUESTION 40
A compiler translates the assembly language instructions into machine language.
True
False
1 points
QUESTION 41
An identifier can be declared anywhere including within a class, and outside of every method
definition (and every block).
True
False
1 points
QUESTION 42
The following for loop executes 21 times. (Assume all variables are properly declared.)
for (i = 1; i <= 20; i = i + 1)
System.out.println(i);
True
False
1 points
QUESTION 43
Which of the following is the array subscripting operator in Java?
.
{}
new
[]
1 points
QUESTION 44
char[][] table = new char[10][5];
How many columns are in the array seen in the accompanying figure?
0
5
10
15
1 points
QUESTION 45
The digit 0 or 1 is called a ____.
bit
bytecode
Unicode
hexcode
1 points
QUESTION 46
The output of the following Java code is: Stoor.
int count = 5;
System.out.print("Sto");
do
{
System.out.print('o');
count--;
}
while (count >= 5);
System.out.println('r');
True
False
1 points
QUESTION 47
The expression (double)(5 + 4) evaluates to ____.
8
9
9.0
10.0
1 points
QUESTION 48
In Java, !, &&, and || are called logical operators.
True
False
1 points
QUESTION 49
int x, y;
if (x < 4)
y = 2;
else if (x > 4)
{
if (x > 7)
y = 4;
else
y = 6;
}
else
y = 8;
Based on the code above, what is the value of y if x = 4?
2
4
6
8
1 points
QUESTION 50
What is the output of the following code?
int count;
int num = 2;
for (count = 1; count < 2; count++)
{
num = num + 3;
System.out.print(num + " ");
}
System.out.println();
5
5 8
2 5 8
5 8 11
0
5
10
15
Solution
Question 1:
char[][] table = new char[10][5];
How many rows are in the array seen in the accompanying figure?
Answer : 5
Question 2: The standard output object in Java is ____.
Answer : System.out
Question 3: The length of the string "first java program" is:
Answer : 18

More Related Content

PDF
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
PPTX
Java Quiz
PDF
Test Bank for Java Programming, 7th Edition
PDF
Get Test Bank for Java Programming, 7th Edition free all chapters
PDF
Test Bank for Java Programming, 7th Edition
PPTX
Long Quiz for Java Programming - Basics plus Array and looping .pptx
PDF
Test Bank for Java Programming, 7th Edition
PDF
Java MCQ Questions and Answers PDF By ScholarHat
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
Java Quiz
Test Bank for Java Programming, 7th Edition
Get Test Bank for Java Programming, 7th Edition free all chapters
Test Bank for Java Programming, 7th Edition
Long Quiz for Java Programming - Basics plus Array and looping .pptx
Test Bank for Java Programming, 7th Edition
Java MCQ Questions and Answers PDF By ScholarHat

Similar to All based on Zybooks = AP Java with zylabsPlease answer all questi.pdf (20)

PDF
Test Bank for Java Programming, 7th Edition
PDF
Java MCQ Important Questions and Answers
PDF
ITI COPA Java MCQ important Questions and Answers
PDF
Java Programming.pdf
PDF
Starting Out with Java Early Objects 6th Edition Gaddis Test Bank
DOCX
FSOFT - Test Java Exam
DOCX
1 Midterm Preview Time allotted 50 minutes CS 11.docx
DOCX
ExamName___________________________________MULTIPLE CH.docx
PDF
Starting Out with Java From Control Structures through Objects 6th Edition Ga...
TXT
CORE JAVA
DOCX
Comp 328 final guide
PPTX
OCA_PREPARATION_OCA_1Z0-808_FlashCards.pptx
PDF
Fnt software solutions placement paper
PDF
Java interview question
PPT
Java language fundamentals
PPTX
Javascript
PDF
1z0-808-certification-questions-sample
DOCX
Question 1 1 pts Skip to question text.As part of a bank account.docx
PDF
Core java
Test Bank for Java Programming, 7th Edition
Java MCQ Important Questions and Answers
ITI COPA Java MCQ important Questions and Answers
Java Programming.pdf
Starting Out with Java Early Objects 6th Edition Gaddis Test Bank
FSOFT - Test Java Exam
1 Midterm Preview Time allotted 50 minutes CS 11.docx
ExamName___________________________________MULTIPLE CH.docx
Starting Out with Java From Control Structures through Objects 6th Edition Ga...
CORE JAVA
Comp 328 final guide
OCA_PREPARATION_OCA_1Z0-808_FlashCards.pptx
Fnt software solutions placement paper
Java interview question
Java language fundamentals
Javascript
1z0-808-certification-questions-sample
Question 1 1 pts Skip to question text.As part of a bank account.docx
Core java
Ad

More from deepakarora871 (20)

PDF
please show stepsworking thanks Simplify Sin theta (cosec theta - s.pdf
PDF
mutations in the LDL receptor are linked to familial hypercholestero.pdf
PDF
Name at least three ancillary departments in a hospital that dire.pdf
PDF
Linear Algebra QuestionI have been trying at these for hours. I ca.pdf
PDF
Match the following parts of an EKG with what part of the heartbeat t.pdf
PDF
Let X = U+V, U is exponentially distributed with mean = 2 and V is a.pdf
PDF
Lets try to summarize Darwins observations that drive changes in .pdf
PDF
In a single-phase region of a p-v-T diagram, which of the following a.pdf
PDF
If the CFTR doesnt work correctly due to a mutation, Cl^- movement .pdf
PDF
How does the Drosophila embryo get its pair-rule stripes How is the .pdf
PDF
Explain the difference between an assumption and a constraint.So.pdf
PDF
Each group should plot on graph paper the ½ life of the radioisotope.pdf
PDF
Dr. Liu did a genetic screen for yeast cells that fail to synthesize .pdf
PDF
Children with Down Syndrome generally show a pattern of retarded men.pdf
PDF
Choose the statement that describes the first stage of phagocytosis .pdf
PDF
Are logarithms prolems used for career jobsSolutionLogarithmi.pdf
PDF
a) The following is a list of terms to do with how digital informati.pdf
PDF
5. What is the difference between mutually exclusive alternatives and.pdf
PDF
“Our solar system is a molecule on a snowflake on the tip of the ice.pdf
PDF
write the exponential decay function 15. Paleontology Carbon-14 i.pdf
please show stepsworking thanks Simplify Sin theta (cosec theta - s.pdf
mutations in the LDL receptor are linked to familial hypercholestero.pdf
Name at least three ancillary departments in a hospital that dire.pdf
Linear Algebra QuestionI have been trying at these for hours. I ca.pdf
Match the following parts of an EKG with what part of the heartbeat t.pdf
Let X = U+V, U is exponentially distributed with mean = 2 and V is a.pdf
Lets try to summarize Darwins observations that drive changes in .pdf
In a single-phase region of a p-v-T diagram, which of the following a.pdf
If the CFTR doesnt work correctly due to a mutation, Cl^- movement .pdf
How does the Drosophila embryo get its pair-rule stripes How is the .pdf
Explain the difference between an assumption and a constraint.So.pdf
Each group should plot on graph paper the ½ life of the radioisotope.pdf
Dr. Liu did a genetic screen for yeast cells that fail to synthesize .pdf
Children with Down Syndrome generally show a pattern of retarded men.pdf
Choose the statement that describes the first stage of phagocytosis .pdf
Are logarithms prolems used for career jobsSolutionLogarithmi.pdf
a) The following is a list of terms to do with how digital informati.pdf
5. What is the difference between mutually exclusive alternatives and.pdf
“Our solar system is a molecule on a snowflake on the tip of the ice.pdf
write the exponential decay function 15. Paleontology Carbon-14 i.pdf
Ad

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Lesson notes of climatology university.
PDF
Trump Administration's workforce development strategy
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Classroom Observation Tools for Teachers
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Lesson notes of climatology university.
Trump Administration's workforce development strategy
Supply Chain Operations Speaking Notes -ICLT Program
Pharma ospi slides which help in ospi learning
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
202450812 BayCHI UCSC-SV 20250812 v17.pptx
human mycosis Human fungal infections are called human mycosis..pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Yogi Goddess Pres Conference Studio Updates
Classroom Observation Tools for Teachers

All based on Zybooks = AP Java with zylabsPlease answer all questi.pdf

  • 1. All based on Zybooks = AP Java with zylabs Please answer all questions - no explanation of answers needed QUESTION 1 char[][] table = new char[10][5]; How many rows are in the array seen in the accompanying figure? 0 5 10 15 QUESTION 2 The standard output object in Java is ____. output System.out Sys.out System.in QUESTION 3 The length of the string "first java program" is: 16 18 19 20 1 points QUESTION 4 The loop condition of a while loop is reevaluated before every iteration of the loop. True False 1 points QUESTION 5 If str1 is “Hello” and str2 is “Hi”, which of the following could not be a result of str1.compareTo(str2);? -9 -5 -1 1
  • 2. 1 points QUESTION 6 Both System.out.println and System.out.print can be used to output a string on the standard output device. True False 1 points QUESTION 7 In a method call statement, when passing an array as an actual parameter, you use only its name. True False 1 points QUESTION 8 Which of the following is true about a while loop? The body of the loop is executed at least once. The logical expression controlling the loop is evaluated before the loop is entered and after the loop exists. The body of the loop may not execute at all. It is a post-test loop 1 points QUESTION 9 int x, y; if (x < 4) y = 2; else if (x > 4) { if (x > 7) y = 4; else y = 6; } else y = 8; Based on the code above, what is the value of y if x = 9?
  • 3. 2 4 6 8 1 points QUESTION 10 The array index can be any nonnegative integer less than the array size. True False 1 points QUESTION 11 When a program executes, the first statement to execute is always the first statement in the main method. True False 1 points QUESTION 12 Java stores two-dimensional arrays in a row order form in computer memory. True False 1 points QUESTION 13 The statement dataType[][][] arrayName; would declare a two-dimensional array. True False 1 points QUESTION 14 All the methods defined in a class must have different names. True False 1 points QUESTION 15 Which of the following is NOT a reserved word in Java? double throws static
  • 4. num 1 points QUESTION 16 Given the declaration int[] list = new int[50]; the statement System.out.println(list[0] + "..." + list[49]); outputs all 50 components of the array list. True False 1 points QUESTION 17 In the case of an infinite while loop, the while expression (that is, the loop condition) is always true. True False 1 points QUESTION 18 Consider the following program. public class CircleArea { static Scanner console = new Scanner(System.in); static final double PI = 3.14; public static void main(String[]args) { doubler; double area; r = console.nextDouble(); area = PI * r * r; System.out.println("Area = " + area);
  • 5. } } To successfully compile this program, which of the following import statement is required? import java.io.Scanner; import java.util.Scanner; import java.lang.Scanner; No import statement is required 1 points QUESTION 19 An identifier can be any sequence of characters and integers. True False 1 points QUESTION 20 A single array can hold elements of many different data types. True False 1 points QUESTION 21 Consider the following program. // Insertion Point 1 public class CircleArea { // Insertion Point 2 static final float PI = 3.14 public static void main(String[]args) { //Insertion Point 3 float r = 2.0; float area; area = PI * r * r; System.out.println("Area = " + area);
  • 6. } // Insertion Point 4 } In the above code, where do the import statements belong? Insertion Point 1 Insertion Point 2 Insertion Point 3 Insertion Point 4 1 points QUESTION 22 Suppose that x is an int variable. Which of the following expressions always evaluates to false? (x > 0) || (x <= 0) (x > 0) || (x == 0) (x > 0) && ( x <= 0) (x >= 0) && (x == 0) 1 points QUESTION 23 What is the value of alpha[4] after the following code executes? int[] alpha = new int[5]; for (int j = 0; j < 5; j++) alpha[j] = 2 * j - 1; one three five seven 1 points QUESTION 24 If a = 4; and b = 3;, then after the statement a = b; executes, the value of b is 4 and the value of a is 3. True False 1 points QUESTION 25
  • 7. The expression !(x <= 0) is true only if x is a positive number. True False 1 points QUESTION 26 In a return method, the last line of the method must be a return statement. True False 1 points QUESTION 27 The expression (int)8.7 evaluates to ____. 8 8.0 9.0 9 1 points QUESTION 28 A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met. True False 1 points QUESTION 29 What is stored in alpha after the following code executes? int[] alpha = new int[5]; for (int j = 0; j < 5; j++) { alpha[j] = 2 * j; if (j % 2 == 1) alpha[j - 1] = alpha[j] + j; } alpha = {0, 2, 4, 6, 8} alpha = {3, 2, 9, 6, 8}
  • 8. alpha = {0, 3, 4, 7, 8} alpha = {0, 2, 9, 6, 8} 1 points QUESTION 30 Suppose that x and y are int variables and x = 7 and y = 8. After the statement: x = x * y - 2; executes, the value of x is ____. 42 54 56 58 1 points QUESTION 31 A counter-controlled loop should be used when the programmer knows the exact number of loop iterations are needed. True False 1 points QUESTION 32 In Java, a period is used to terminate a statement. True False 1 points QUESTION 33 In Java, return is a reserved word. True False 1 points QUESTION 34 When an array reference is passed to a method, the method can modify the elements of the array object. True False 1 points QUESTION 35 A local identifier is an identifier that is declared within a method or block and that is visible only within that method or block.
  • 9. True False 1 points QUESTION 36 An expression such as str.length(); is an example of a(n) ____. system call object call class method call 1 points QUESTION 37 Suppose str1 and str2 are String variables. The expression (str1 == str2) determines whether str1 and str2 reference the same String object. True False 1 points QUESTION 38 Just like the nesting of loops, Java allows the nesting of methods. True False 1 points QUESTION 39 Suppose console is a Scanner object initialized with the standard input device. The expression console.nextInt(); is used to read one int value and the expression console.nextDouble(); is used to read two int values. True False 1 points QUESTION 40 A compiler translates the assembly language instructions into machine language. True False 1 points QUESTION 41 An identifier can be declared anywhere including within a class, and outside of every method definition (and every block).
  • 10. True False 1 points QUESTION 42 The following for loop executes 21 times. (Assume all variables are properly declared.) for (i = 1; i <= 20; i = i + 1) System.out.println(i); True False 1 points QUESTION 43 Which of the following is the array subscripting operator in Java? . {} new [] 1 points QUESTION 44 char[][] table = new char[10][5]; How many columns are in the array seen in the accompanying figure? 0 5 10 15 1 points QUESTION 45 The digit 0 or 1 is called a ____. bit bytecode Unicode hexcode 1 points QUESTION 46 The output of the following Java code is: Stoor. int count = 5;
  • 11. System.out.print("Sto"); do { System.out.print('o'); count--; } while (count >= 5); System.out.println('r'); True False 1 points QUESTION 47 The expression (double)(5 + 4) evaluates to ____. 8 9 9.0 10.0 1 points QUESTION 48 In Java, !, &&, and || are called logical operators. True False 1 points QUESTION 49 int x, y; if (x < 4) y = 2; else if (x > 4) { if (x > 7) y = 4; else y = 6;
  • 12. } else y = 8; Based on the code above, what is the value of y if x = 4? 2 4 6 8 1 points QUESTION 50 What is the output of the following code? int count; int num = 2; for (count = 1; count < 2; count++) { num = num + 3; System.out.print(num + " "); } System.out.println(); 5 5 8 2 5 8 5 8 11 0 5 10 15 Solution Question 1: char[][] table = new char[10][5];
  • 13. How many rows are in the array seen in the accompanying figure? Answer : 5 Question 2: The standard output object in Java is ____. Answer : System.out Question 3: The length of the string "first java program" is: Answer : 18