| When a method doesn't modify the object on which it is invoked, it is called a(n) __________ method. |
accessor |
|
Given this statement:
String river = "Mississippi";
what is the result of the following call:
river.replace("issipp", "our").length()
|
8 |
|
Write the code to construct a Rectangle with its top-left corner at (100, 50), a width of 60, and a height of 40. Do not assign it to a variable. |
new Rectangle(100, 50, 60, 40) |
|
| Write the code to construct a square with its center at (50, 50) and a side length of 20. Do not assign it to a variable. |
new Rectangle(40, 40, 20, 20) |
|
The getWidth() method of the Rectangle class returns the width of the rectangle. What is the return type of this method? If you are not sure, look it up in the API documentation. |
double |
|
What does the following sequence of statements print?
Rectangle box = new Rectangle(5, 10, 20, 30);
box.translate(25, 40);
System.out.println(box.getX());
|
30 |
|
What does the following sequence of statements print?
String greeting = "Udacity";
System.out.print(greeting.toUpperCase());
System.out.print(" ");
System.out.println(greeting);
|
UDACITY Udacity |
|
Look at the String class in the Java API. What is the type of the parameter of the charAt method? |
int |
|
Look at the Rectangle class in the Java API. What is the return type of the getX method? |
double |
|
What does the following code segment print?
Rectangle box = new Rectangle(50, 100, 20, 30);
Rectangle box2 = box;
box2.translate(15, 25);
System.out.print(box.getY());
System.out.print(" ");
System.out.println(box2.getY());
|
125 125 |
|
What does this code segment print?
int score = 100;
int score2 = score;
score2 = 80;
System.out.print(score);
System.out.print(" ");
System.out.println(score2);
|
100 80 |
|
What does this program print?
public class Test
{
public static void main(String[] args)
{
System.out.print("42+7");
System.out.print(42+7);
System.out.print(" Hello ");
System.out.println("World");
}
}
|
42+749 Hello World |
|