1. In the following example, the __________ asks for an object to be constructed.
2. The following expression (when the program is run) creates a new _____ object by following the description contained in the _____ class.
3. Refer to the code in question 1. Is the following statement true or false?
4. Again, referring to the code in question 1, the declaration "String str;" creates a reference variable, but does not create a String object.
5. The following statement _________________________________.
6. The syntax for creating new objects is as follows. The constructor name ___________________.
7. Which statement would we use to create an object from ExampleClass?
8. Which of the following statements is true of this code? (refer to the 'Objects Example' code, with reference to the code above it.
9. Constructors are said to be ____________ when there are multiple constructors with the same name but a different signature.
10. ____________ allow values to be passed to the?constructor to establish the initial state of?the object.
11. The keyword ___ is a special value used to indicate that a reference is not associated with any object
12. The memory associated with a variable of a reference type holds an object reference value or, if there is no object, _____.
13. Which statement in the Main class will cause an error?
14. Refer to the code below and decide which of the following lines is invoking an object's method.
15. Refer to the code in the previous question. Which line is creating an object of type String?
16. An object consists of both variables (state information) and ________(small programs). Both of these are called members of the object.
17. To access the members of an object in Java, we use ______________.
18. To invoke the length() method of the object named str1 what would you type?
19. To store the value computed by the length method in a variable, what would you type?
20. A ____is like a cookie cutter that can be used many times to make many cookies. There is only one cookie cutter, but can be used to make many cookies.
21. Fill in the blanks for the following statement.
22. A program can execute a static method without first creating an object! All other methods (those that are not static) exist only when they are part of an object.
23. Explore the code below. How many objects are there here?
String prompt1 = "Press Enter to Continue."
String prompt2 = "Press Enter to Continue."
String prompt3 = "Press Enter to Continue."
String prompt4 = "Press Enter to Continue."
24. What is the output of the following program?
25. In the above code the variable _____ is used to refer to this object. In other words, ____ gives the object a name.
26. What happens when you compile the below class?
27. The output of the following program will be: 3,2,1 Null
28. What is the output of this code?
class A
{
static int i;
static
{
System.out.println(1);
i = 100;
}
}
public class StaticInitializationBlock
{
static
{
System.out.println(2);
}
public static void main(String[] args)
{
System.out.println(3);
System.out.println(A.i);
}
}
2,3,1,100
100,2,3,1
100,1
1,2,3,100
29. What is the output of this code? (note: Parameter values are passed by value in the calling of a method -a copy of the value is created in the method, and the original value is not affected by the method call.)