Exam 16: RGB Colors, Decimal Conversion, Java Naming, and Random Number Generation

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

An array, letters, has been declared and initialized as follows: char [ ] letters = { 'A', 'B', 'A', 'C', 'E', 'D' }; What is the index of C? What is the array element at index 1? Swap the value at indexes 3 and 5 (C and D) without knowing what the values are. After the swap, the array will look like A B A D E C. Using a loop, assume that you do not know how many elements are in the array and the contents of the array, and compute and output how many As are in the array letters. Using a loop, assume that you do not know how many elements are in the array and the contents of the array, and change all the As of letters into Zs; do not change the other letters.

(Essay)
4.8/5
(40)

Place the following steps required to calculate a minimum value in the correct order. -Compare a value to the current minimum.

(Short Answer)
4.9/5
(41)

Convert the String input below to a double and display 5 times that value. Do not hard code either 12.4 or 62.0; assume that you do not know the value of input. String input = "12.4";

(Essay)
4.9/5
(40)

Why will there be zero iterations of the while loop if the loop condition is false the first time it is evaluated?

(Essay)
4.7/5
(32)

Convert the following numbers to decimal: 0010 1010 (binary) and 2B (hexadecimal).

(Essay)
4.8/5
(39)

Complete the code, drawing a line between points (100, 200) and (34, 67). // gc is a GraphicsContext reference // your code goes here

(Essay)
4.8/5
(35)

Complete the code, drawing a rectangle (with the current color, whatever it is) so that the coordinates of its upper left corner are (100, 200) and the coordinates of its bottom right corner are (175, 225). // gc is a GraphicsContext reference // your code goes here

(Short Answer)
4.9/5
(34)

Where is the error in the following code sequence, and why? How would you correct it? int number = 6; double d = number; number = 19.0;

(Essay)
4.9/5
(34)

The ArrayList method indexOf has the following API: public int indexOf( HYPERLINK "http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html" \o "class in java.lang" Object o) Return the index of the first occurrence of o in this list or -1 if this list does not contain o. ArrayList cities = new ArrayList( ); cities.add( "Baltimore" ); // more statements adding cities to the ArrayList cities Use indexOf to retrieve the index of the city New York in cities (it may or may not be there) and assign the result to a variable of your choice.

(Short Answer)
4.9/5
(41)

Give the values that are assigned to each variable after the statements below are executed. -int h = 5 + 10 * 3; _________+

(Short Answer)
4.9/5
(34)

Give the values that are assigned to each variable after the statements below are executed. -int e = 5 + 10 / 3; __________

(Short Answer)
4.9/5
(29)

Code a recursive method that takes a String as its only parameter and returns a String that is the same as the parameter String except that all of its As have been removed (all of the As, not just the first A). If an A is not in the parameter String, then the same String is returned.

(Essay)
4.7/5
(38)

I is an interface, A is an abstract class, and B and C are regular classes. C inherits from B (i.e., B is the superclass of C). List all the errors. A a = new A( ); // 1 B b1 = new B( ); // 2 C c1 = new C( ); // 3 I i = new I( ); // 4 B b2 = new C( ); // 5 C c2 = new B( ); // 6

(Essay)
4.9/5
(40)

A String variable named s has been declared and holds some value. If its number of characters is even and greater than or equal to 10, output EVEN AND LONG, otherwise, output ODD OR SHORT.

(Essay)
4.8/5
(41)

A String variable named email contains the email of a person in this format: username@serviceProvider.extension. Examples are mike32@yahoo.com and jane21@gmail.com. For simplicity, assume that there is exactly one @ character and one . (dot) character in the String email, and that the @ character is before the . (dot) character. Output the username, the service provider, and the extension of email.

(Essay)
4.7/5
(38)

Write a loop to calculate the total of all the numbers between 100 and 200 included (i.e., 100 + 101 + … + 199 + 200); output the total.

(Essay)
4.8/5
(39)

Complete the code, drawing a triangle whose edges are blue and whose vertices are the points (100, 125), (150, 200), and (100, 300). // gc is a GraphicsContext reference // your code goes here

(Essay)
4.7/5
(39)

Assuming a is an int variable and flag is a boolean variable, apply one of DeMorgan's laws to create an equivalent expression for the following boolean expression: !( a == 100 || flag == false )

(Short Answer)
4.9/5
(39)

Write a loop to output the word EXAM 99 times.

(Essay)
4.8/5
(30)

The ArrayList method trimToSize has the following API: public void trimToSize( ) It trims the capacity of this ArrayList instance to be the list's current size. ArrayList numbers = new ArrayList( ); numbers.add( 32 ); numbers.add( 17 ); numbers.add( 6 ); Use trimToSize to trim the capacity of numbers to its current size:

(Short Answer)
4.9/5
(45)
Showing 61 - 80 of 110
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)