Ace - AI Tutor
Ask Our Educators
Textbooks
My Library
Flashcards
Scribe - AI Notes
Notes & Exams
Download App
Lilly Brown

Lilly B.

Divider

Viewed Questions

Consider these class declarations:
Which is a true statement?
I Teacher inherits the constructors of Person. II Teacher can add new methods and private instance variables. III Teacher can override existing private methods of Person.
(A) I only
(B) II only
(C) III only
(D) I and II only
(E) II and III only

Consider these class declarations: Which is a true statement? I Teacher inherits the constructors of Person. II Teacher can add new methods and private instance variables. III Teacher can override existing private methods of Person. (A) I only (B) II only (C) III only (D) I and II only (E) II and III only

Barron's AP Computer Science A

Questions asked

ANSWERED

Willis James verified

Numerade educator

Consider the following code: String[] fruits = {"doggie", "badger", "cat", "gopher"}; int i = 3; String str = "d"; for(String item : fruits) { i = item.indexOf("d") + 2; str += item.substring(i); } System.out.println(str); Assume that the loop accesses array elements in order. What is output by this code?

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

The following method is intended to remove all values from the ArrayList < Integer > aList that have the same value as val; however, this method does NOT work correctly. public void removeValue(ArrayList < Integer > aList, int val) { int i; for(i = 0; i < aList.size(); i++) { if(aList.get(i) == val) { aList.remove(i); } } } If aList initially contains 2 3 4 3 3 4 4 5 4 3 2 1 and val is equal to 3, then aList should contain 2 4 4 4 5 4 2 1 after removeValue is invoked. What does aList actually contain after removeValue is invoked? 2 4 4 4 5 4 2 1 2 4 3 4 4 5 4 2 1 2 4 4 3 4 4 5 4 2 1 2 4 3 4 4 5 4 3 2 1 2 4 3 3 4 4 5 4 3 2 1

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

Consider the following method: public int mystery(int n) { if(n > 6) { return 1 + mystery(n - 1); } return n % 3; } What is the value of mystery(10)? 4 6 8 9 10

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

Consider the method below. What would the result of test(3) be? public static int test(int n) { if (n == 0) return 3; else return 2 * test(n - 1); } 1 3 6 12 24

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

Consider an integer array, vals, which has been declared with one or more integer values. Which of the code segments updates vals so that each element contains the current value less 2? for (int v: vals) { v = v −2; } for (int m = 0; m < vals.length; m++ ) { vals[m] = vals[m] −2; } int m = 0; while (m < vals.length) { vals[m] = vals[m] − 2; } II only III only I and III II and III I, II, and III

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

Which of the following expressions is equivalent to !(a && b)? (a || b) (!a) && (!b) (a != b) (!a) || (!b) (a && b)

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

The code segment below should print "9 7 5 3 1". 1 int x = 9; 2 while (x >= 1) { System.out.print(x + " "); 3 x--; } Does it work as intended? If NOT, what code segment below would correct it? Line 3: x− = 2; Line 1: int x = 10; Line 2: while (x > 1) Line 2: while (x < 1) The code runs as expected

View Answer
divider
ANSWERED

Luke Humphrey verified

Numerade educator

Consider the code segment below. int x = 3; int y = 5; int z = 12; if (x > 0 && y <= 10) { System.out.println(y − x * z % x + y); } What would print as a result? 0 1 5 10 11

View Answer
divider
ANSWERED

Eduard Sanchez verified

Numerade educator

Consider the code block below. for (int x = 0; x < 5; x++ ) { for (int y = 1; y < x; y++ ) { System.out.print(x + " "); } } What is the result when the code executes? 1 2 3 4 1 2 2 3 3 3 4 4 4 4 2 2 3 3 4 4 2 3 3 4 4 4 2 2 2 3 3 3 4 4 4

View Answer
divider
ANSWERED

Willis James verified

Numerade educator

Consider the code block below. String str = " hi "; for (int x = 0; x < 3; x++ ) { for (int y = 1; y < 1; y++ ) { System.out.print(x + str); } } What is the result when the code executes? 2hi 2hi 2hi 3hi 2 hi 2 hi 3 hi Nothing is printed

View Answer
divider