Question
What code will set the last element of array b to 9? Question 1 options: b[ b.length-1 ] = 9; b[-1] = 9; b[ b.length
What code will set the last element of array b to 9?
Question 1 options:
b[ b.length-1 ] = 9; | |
b[-1] = 9; | |
b[ b.length ] = 9; | |
b = 9; |
Question 2 (1 point)
If you create an array of ints, what value will the elements of the array have initially?
Your Answer:Question 2 options:
Answer |
Question 3 (1 point)
Which code below properly declares an array of String with 8 elements?
Question 3 options:
new String[] = String[8]; | |
String[] s = new String[8]; | |
String[] s = 8; | |
String s[8]; |
Question 4 (1 point)
In the code below, what is the value of a[1]?
int[] a = new int[3]; int[] b = a; b[1] = 3; a[1] += 2;
Your Answer:Question 4 options:
Answer |
Question 5 (1 point)
Suppose b is an array of String. What does this code do? String[] c = b;
Question 5 options:
c points to the same array as b. | |
c becomes a copy of b. | |
It is an error, since c and b do not have the same name. | |
c and b have the same size, but the values in c are all null. |
Question 6 (1 point)
What does the following code do? int[] b = new int[5]; int[] c = b; c[1] = 3;
Question 6 options:
b and c are arrays that both have the value 5 in them. | |
b and c point to different arrays. c[1] is 3, and b[1] is 0. | |
b and c point to the same array, and element 1 of that array is 3. | |
b and c point to the same array, and all the elements of both are 3. |
Question 7 (1 point)
Suppose you want to print an grid of numbers using the code below: for (int r=0; r<5; r++) { for (int c=0; c<4; c++) { System.out.print((r+c) + " "); } System.out.println(); }
How many rows will the grid have?
Your Answer:Question 7 options:
Answer |
Question 8 (1 point)
What is a code block enclosed in?
Question 8 options:
Curly braces | |
Quotes | |
Brackets | |
Parentheses |
Question 9 (1 point)
Suppose you want to print an n x n grid of x's. What code would you place at "// your code here"? for (int r=0; r Question 9 options: System.out.println("x"); System.out.print(c); if (r==c) System.out.print("x"); System.out.print("x"); Question 10 (1 point) The increment part of a for loop is the first thing in the loop that executes. Question 10 options: Question 11 (1 point) If a continue statement happens in a for loop, the increment part of the loop will still execute for that iteration. Question 11 options: Question 12 (1 point) Java reserves certain words for special purposes. Which of the following is not a reserved word? Question 12 options: elseif if class public Question 13 (1 point) + has higher precedence than % Question 13 options: Question 14 (1 point) Which line of code will set the String s to the value "happy"? Question 14 options: s <- "happy"; set s to "happy"; "happy" = s; s = "happy"; Question 15 (1 point) Which of the following will print the String "hello"? Question 15 options: system.out.println(hello); echo "hello"; System.Out.Println("hello"); System.out.println("hello");
True False
True False
True False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started