Deck 2: Using Objects
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/76
Play
Full screen (f)
Deck 2: Using Objects
1
A set of values and the operations that can be carried out with those values are called _______.
A) literals
B) numbers
C) values
D) types
A) literals
B) numbers
C) values
D) types
D
2
What is the name of the = operator in Java?
A) inequality
B) assignment
C) identity
D) equality
A) inequality
B) assignment
C) identity
D) equality
B
3
Which of the following declares a variable that will store a measurement with fractional parts?
A) int measure;
B) double measure;
C) String measure;
D) integer measure;
A) int measure;
B) double measure;
C) String measure;
D) integer measure;
B
4
Which of the following declares a variable that will store a count with an integer value?
A) integer count;
B) double count;
C) String count;
D) int count;
A) integer count;
B) double count;
C) String count;
D) int count;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
5
What is the purpose of the assignment operator?
A) to check for inequality
B) to check for identity
C) to check for equality
D) to change the value of a variable
A) to check for inequality
B) to check for identity
C) to check for equality
D) to change the value of a variable
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
6
By convention, classes begin with a(n) _____________.
A) lowercase letter
B) dollar sign
C) digit
D) uppercase letter
A) lowercase letter
B) dollar sign
C) digit
D) uppercase letter
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
7
By convention, variables begin with a(n) _____________.
A) uppercase letter
B) digit
C) lowercase letter
D) dollar sign
A) uppercase letter
B) digit
C) lowercase letter
D) dollar sign
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
8
What is the name of the type that denotes whole numbers?
A) double
B) int
C) whole
D) integer
A) double
B) int
C) whole
D) integer
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
9
Which statement stores an integer value in a variable?
A) count = 5;
B) String count = 5;
C) int count;
D) integer count = 5;
A) count = 5;
B) String count = 5;
C) int count;
D) integer count = 5;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
10
Which statement declares a variable that will store an integer value?
A) integer count;
B) int count;
C) count = 5;
D) String count = 5;
A) integer count;
B) int count;
C) count = 5;
D) String count = 5;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
11
Which term is used to describe the name of a variable, method, or class?
A) type
B) literal
C) identifier
D) label
A) type
B) literal
C) identifier
D) label
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
12
Which statement declares and stores an integer value in a variable?
A) count = 5;
B) int count = 5;
C) integer count = 5;
D) String count = 5;
A) count = 5;
B) int count = 5;
C) integer count = 5;
D) String count = 5;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
13
What is the name of the type that denotes a string of characters?
A) Characters
B) char
C) charString
D) String
A) Characters
B) char
C) charString
D) String
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following values does not have a primitive type?
A) 12.50
B) "Hello"
C) 6
D) 1E4
A) 12.50
B) "Hello"
C) 6
D) 1E4
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following is the best choice for a variable identifier that will store a name?
A) name
B) Name
C) n
D) nm
A) name
B) Name
C) n
D) nm
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
16
Which is a valid number literal?
A) 1x10^4
B) 1E4
C) 3 1/2
D) 10,000
A) 1x10^4
B) 1E4
C) 3 1/2
D) 10,000
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
17
Which statement about identifiers is correct?
A) Identifiers are not case sensitive.
B) Spaces are permitted inside identifiers.
C) Identifiers can use symbols such as ? or %.
D) Identifiers can be made up of letters, digits, and the underscore (_) character.
A) Identifiers are not case sensitive.
B) Spaces are permitted inside identifiers.
C) Identifiers can use symbols such as ? or %.
D) Identifiers can be made up of letters, digits, and the underscore (_) character.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following declares a variable that will store a welcome message?
A) String welcome;
B) double welcome;
C) Char welcome;
D) int welcome;
A) String welcome;
B) double welcome;
C) Char welcome;
D) int welcome;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
19
What is the name of the type that denotes floating-point numbers that can have fractional parts?
A) double
B) floatingPoint
C) int
D) integer
A) double
B) floatingPoint
C) int
D) integer
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
20
What is a storage location in the computer's memory called that has a type, name, and contents?
A) identifier
B) literal
C) label
D) variable
A) identifier
B) literal
C) label
D) variable
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
21
Assume that the variable count has been declared as type int. Which statement adds 10 to count?
A) count = 10;
B) count == count + 10;
C) count = count + 10;
D) count + 10;
A) count = 10;
B) count == count + 10;
C) count = count + 10;
D) count + 10;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following statements about objects is correct?
A) An object defines the methods for a class.
B) Every object belongs to a class.
C) An object is a sequence of instructions.
D) All entities, even numbers, are objects.
A) An object defines the methods for a class.
B) Every object belongs to a class.
C) An object is a sequence of instructions.
D) All entities, even numbers, are objects.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following statements about methods is correct?
A) A method is a sequence of instructions that could access the data of an object
B) A method name is unique across the entire program.
C) A method can be called on any object in any class.
D) Methods are stored in variables.
A) A method is a sequence of instructions that could access the data of an object
B) A method name is unique across the entire program.
C) A method can be called on any object in any class.
D) Methods are stored in variables.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
24
Input to a method enclosed in parentheses after the method name is known as ______________.
A) implicit parameters
B) interfaces
C) explicit parameters
D) return values
A) implicit parameters
B) interfaces
C) explicit parameters
D) return values
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following statements about classes is correct?
A) By convention, class names begin with a lowercase letter.
B) A class declares the methods that you can apply to its objects.
C) All entities, even primitive numbers, are classes.
D) A class is a sequence of instructions that accesses the data of an object.
A) By convention, class names begin with a lowercase letter.
B) A class declares the methods that you can apply to its objects.
C) All entities, even primitive numbers, are classes.
D) A class is a sequence of instructions that accesses the data of an object.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
26
Assume that the variable count has been declared as type int, which statement changes the value of count?
A) count = 6;
B) count == 6;
C) integer count = 6;
D) count := 6;
A) count = 6;
B) count == 6;
C) integer count = 6;
D) count := 6;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
27
What is the type of an object?
A) variable
B) method
C) reference
D) class
A) variable
B) method
C) reference
D) class
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
28
If greeting is a String object, which method call is incorrect?
A) greeting.length()
B) greeting.toLowerCase()
C) greeting.toUpperCase()
D) greeting.println()
A) greeting.length()
B) greeting.toLowerCase()
C) greeting.toUpperCase()
D) greeting.println()
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following statements about methods is correct?
A) A method can have only one explicit parameter.
B) The return value of a method can be used as a parameter.
C) Every method must have a return value.
D) A method can have multiple implicit parameters.
A) A method can have only one explicit parameter.
B) The return value of a method can be used as a parameter.
C) Every method must have a return value.
D) A method can have multiple implicit parameters.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
30
Which is not a method of the String class?
A) length
B) toUpperCase
C) toLowerCase
D) println
A) length
B) toUpperCase
C) toLowerCase
D) println
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
31
Which method call represents the invocation of a method that does not have explicit parameters?
A) greeting.replace("Hello", "Welcome");
B) greeting.length
C) greeting.length()
D) System.out.println(greeting);
A) greeting.replace("Hello", "Welcome");
B) greeting.length
C) greeting.length()
D) System.out.println(greeting);
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
32
The object on which the method call is invoked provides input to the method, and is called a(n) _________________.
A) interface
B) procedure
C) implicit parameter
D) explicit parameter
A) interface
B) procedure
C) implicit parameter
D) explicit parameter
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
33
What is an object?
A) A sequence of instructions.
B) Any value stored in a variable.
C) An entity in your program that is manipulated by calling methods.
D) Any input to a method.
A) A sequence of instructions.
B) Any value stored in a variable.
C) An entity in your program that is manipulated by calling methods.
D) Any input to a method.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
34
The output of a method is called its __________ value.
A) implicit
B) explicit
C) parameter
D) return
A) implicit
B) explicit
C) parameter
D) return
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
35
"System.out" is an instance of (example of?) which class?
A) String
B) Println
C) System
D) PrintStream
A) String
B) Println
C) System
D) PrintStream
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
36
A method name is ____________________ if a class has more than one method with that name (but different parameter types).
A) overridden
B) overimplemented
C) overwhelmed
D) overloaded
A) overridden
B) overimplemented
C) overwhelmed
D) overloaded
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
37
The input to a method is called a(n) _______________.
A) overloaded
B) parameter
C) interface
D) procedure
A) overloaded
B) parameter
C) interface
D) procedure
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following code fragments will cause an error?
A) String greeting = "Hello, Dave!";
B) String greeting = "Hello, World!"; int n = greeting.length();
C) int luckyNumber; System.out.println(luckyNumber);
D) PrintStream printer = System.out;
A) String greeting = "Hello, Dave!";
B) String greeting = "Hello, World!"; int n = greeting.length();
C) int luckyNumber; System.out.println(luckyNumber);
D) PrintStream printer = System.out;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
39
What is the term used to specify the remote control for a class, indicating what you can do with the objects that belong to the class?
A) private interface
B) public interface
C) private implementation
D) hidden implementation
A) private interface
B) public interface
C) private implementation
D) hidden implementation
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
40
Which of the following method calls illustrates the return value of a method as a parameter?
A) greeting.length();
B) greeting.println("Hello");
C) System.out.println(length.greeting());
D) System.out.println(greeting.length());
A) greeting.length();
B) greeting.println("Hello");
C) System.out.println(length.greeting());
D) System.out.println(greeting.length());
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
41
Which statement calls a constructor with no construction parameters?
A) Circle c = new Circle();
B) A call to a constructor must have construction parameters.
C) Circle c = new Circle;
D) Circle c = Circle()
A) Circle c = new Circle();
B) A call to a constructor must have construction parameters.
C) Circle c = new Circle;
D) Circle c = Circle()
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
42
To use a class in another package you need to ________ it.
A) export
B) overload
C) rewrite
D) import
A) export
B) overload
C) rewrite
D) import
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following represents a method call to a method with a void return type?
A) greeting.isEmpty()
B) System.out.println()
C) greeting.replace("Hello","World")
D) greeting.length()
A) greeting.isEmpty()
B) System.out.println()
C) greeting.replace("Hello","World")
D) greeting.length()
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
44
What terminology describes a method that modifies the internal data of its implicit parameter?
A) public
B) void
C) mutator
D) accessor
A) public
B) void
C) mutator
D) accessor
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following constructs a Circle of radius 3, assuming the construction parameter is the radius value?
A) Circle(3).new
B) new Circle(3)
C) new.Circle(3)
D) Circle(3)
A) Circle(3).new
B) new Circle(3)
C) new.Circle(3)
D) Circle(3)
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
46
A _____________ is a collection of classes with a related purpose.
A) package
B) import
C) method
D) collection
A) package
B) import
C) method
D) collection
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
47
What does API stand for?
A) Applet Programming Interface
B) Application Programmer Interaction
C) Application Programming Instance
D) Application Programming Interface
A) Applet Programming Interface
B) Application Programmer Interaction
C) Application Programming Instance
D) Application Programming Interface
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
48
What is the declared return type for a method that does not have a return value?
A) String
B) There is no declared return type when a method does not return a value.
C) void
D) A method must return a value.
A) String
B) There is no declared return type when a method does not return a value.
C) void
D) A method must return a value.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
49
Which method checks whether a point lies within the rectangle?
A) add
B) getBounds
C) translate
D) contains
A) add
B) getBounds
C) translate
D) contains
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
50
If greeting refers to a String object, which of the following is a syntactically correct Java statement?
A) System.out.println(length().greeting);
B) System.out.println(greeting());
C) System.out.println(greeting.length());
D) greeting.println("Hello");
A) System.out.println(length().greeting);
B) System.out.println(greeting());
C) System.out.println(greeting.length());
D) greeting.println("Hello");
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
51
Which of the following is a mutator method for the Rectangle class?
A) getHeight
B) translate
C) getWidth
D) isEmpty
A) getHeight
B) translate
C) getWidth
D) isEmpty
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
52
Which statement declares a variable that references a Circle of radius 3?
A) Circle c = Circle(3)
B) Circle c = new Circle(3);
C) Circle c.new.Circle(3);
D) c.Circle(3);
A) Circle c = Circle(3)
B) Circle c = new Circle(3);
C) Circle c.new.Circle(3);
D) c.Circle(3);
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
53
Which package is automatically imported in any Java program?
A) java.system
B) java.lang
C) java.language
D) java.util
A) java.system
B) java.lang
C) java.language
D) java.util
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
54
Which method would you use to obtain the string "1234567890" from the string "123-456-7890"?
A) isEmpty
B) replace
C) trim
D) length
A) isEmpty
B) replace
C) trim
D) length
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
55
Which of the following represents a method declaration with a void return type?
A) public void setValue(int value) { ... }
B) public void int getValue() { ... }
C) void public setValue(int value) { ... }
D) void int getValue() { ... }
A) public void setValue(int value) { ... }
B) public void int getValue() { ... }
C) void public setValue(int value) { ... }
D) void int getValue() { ... }
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
56
What terminology describes a method that returns information about its implicit parameter and does not change the parameter's internal data?
A) mutator
B) accessor
C) void
D) public
A) mutator
B) accessor
C) void
D) public
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
57
Which of the following statements about test programs is true?
A) Test programs verify that methods have been implemented correctly.
B) A tester class does not contain the main method.
C) You do not have to display the expected results.
D) Writing test programs is not an important skill.
A) Test programs verify that methods have been implemented correctly.
B) A tester class does not contain the main method.
C) You do not have to display the expected results.
D) Writing test programs is not an important skill.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
58
Which import statement allows for the use of the Rectangle class?
A) import java.geom.Rectangle2D;
B) import java.geom.Rectangle;
C) import java.geom.RectangularShape;
D) import java.awt.Rectangle;
A) import java.geom.Rectangle2D;
B) import java.geom.Rectangle;
C) import java.geom.RectangularShape;
D) import java.awt.Rectangle;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
59
Which operator constructs object instances?
A) new
B) instanceof
C) void
D) construct
A) new
B) instanceof
C) void
D) construct
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
60
Which class is part of the java.lang package?
A) Rectangle
B) PrintStream
C) String
D) Circle
A) Rectangle
B) PrintStream
C) String
D) Circle
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
61
Assuming the following Java statement:
Int num = 10;
What does the variable num store?
A) A reference to the memory location where the value 10 is stored.
B) A reference to the int primitive type.
C) An object representing the number 10.
D) The numeric value 10.
Int num = 10;
What does the variable num store?
A) A reference to the memory location where the value 10 is stored.
B) A reference to the int primitive type.
C) An object representing the number 10.
D) The numeric value 10.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
62
What is the output of the following code:
Int num1 = 6;
Int num2 = num1;
Num2 = num2 + 10;
System.out.println(num1);
A) 6
B) 10
C) 4
D) 16
Int num1 = 6;
Int num2 = num1;
Num2 = num2 + 10;
System.out.println(num1);
A) 6
B) 10
C) 4
D) 16
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
63
What is the output of the following code: Circle c1 = new Circle(3);
Circle c2 = new Circle(3);
C1)setRadius(4);
System.out.println(c2.getRadius());
A) 3
B) 8
C) 6
D) 4
Circle c2 = new Circle(3);
C1)setRadius(4);
System.out.println(c2.getRadius());
A) 3
B) 8
C) 6
D) 4
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
64
Assuming the following Java statement: Circle c1 = new Circle(3);
What does the variable c1 store?
A) The constructed object itself.
B) A reference to the Circle class.
C) A reference to the memory location of the constructed object.
D) The numeric value 3.
What does the variable c1 store?
A) The constructed object itself.
B) A reference to the Circle class.
C) A reference to the memory location of the constructed object.
D) The numeric value 3.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
65
What do object variables store?
A) objects
B) classes
C) references
D) numbers
A) objects
B) classes
C) references
D) numbers
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
66
Place drawing instructions inside the __________ method, which is called whenever the component needs to be repainted.
A) paintComponent
B) draw
C) paint
D) drawComponent
A) paintComponent
B) draw
C) paint
D) drawComponent
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
67
Based on the following code, which of the following statements sets the frame to a width of 400 and a height of 200: final int FRAME_WIDTH = 400;
Final int FRAME_HEIGHT = 200;
JFrame frame = new JFrame();
A) frame.size = (FRAME_WIDTH, FRAME_HEIGHT);
B) frame.addSize(FRAME_WIDTH, FRAME_HEIGHT);
C) frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
D) frame.setSize(FRAME_HEIGHT, FRAME_WIDTH);
Final int FRAME_HEIGHT = 200;
JFrame frame = new JFrame();
A) frame.size = (FRAME_WIDTH, FRAME_HEIGHT);
B) frame.addSize(FRAME_WIDTH, FRAME_HEIGHT);
C) frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
D) frame.setSize(FRAME_HEIGHT, FRAME_WIDTH);
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
68
What is the output of the following code:
Int num1 = 6;
Int num2 = 10;
Num1 = num1 + num2;
Num2 = num1 + num2;
System.out.println(num1 + ", " + num2);
A) 6, 10
B) 16, 16
C) 16, 22
D) 16, 26
Int num1 = 6;
Int num2 = 10;
Num1 = num1 + num2;
Num2 = num1 + num2;
System.out.println(num1 + ", " + num2);
A) 6, 10
B) 16, 16
C) 16, 22
D) 16, 26
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
69
Complete the following statement, which constructs an ellipse. Ellipse2D.Double ellipse =
New ____________________ (x, y, width, height);
A) Double.Ellipse2D
B) Ellipse2D.Double
C) Ellipse2D
D) Double
New ____________________ (x, y, width, height);
A) Double.Ellipse2D
B) Ellipse2D.Double
C) Ellipse2D
D) Double
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
70
Based on the following statement, which of the following statements sets the title of the frame: JFrame frame = new JFrame();
A) frame.title = "An Empty Frame";
B) frame.setTitle(JFrame.EMPTY);
C) frame.addTitle("An Empty Frame");
D) frame.setTitle("An Empty Frame");
A) frame.title = "An Empty Frame";
B) frame.setTitle(JFrame.EMPTY);
C) frame.addTitle("An Empty Frame");
D) frame.setTitle("An Empty Frame");
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
71
Which of the following terms denotes the memory location of an object?
A) implicit parameter
B) mutator method
C) encapsulation
D) object reference
A) implicit parameter
B) mutator method
C) encapsulation
D) object reference
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
72
Complete this code fragment to ensure that the frame is shown: JFrame frame = new JFrame();
A) frame.setVisible(true);
B) frame.visible = true;
C) JFrame.setVisible();
D) frame.setVisible();
A) frame.setVisible(true);
B) frame.visible = true;
C) JFrame.setVisible();
D) frame.setVisible();
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
73
In the code below, write a statement that sets the graphic to green. public class ItalianFlagComponent extends JComponent
{
Public void paintComponent(Graphics
A) g2.setColor(GREEN);
B) g2.SetColor(0, 255, 0);
C) g2.setColor(Color.GREEN);
D) g2.setColor("GREEN");
G) {
Graphics2D g2 = (Graphics2D) g;
Rectangle.Double leftRectangle = new Rectangle.Double(100, 100, 30, 60);
) . .
____
) . .
}
}
{
Public void paintComponent(Graphics
A) g2.setColor(GREEN);
B) g2.SetColor(0, 255, 0);
C) g2.setColor(Color.GREEN);
D) g2.setColor("GREEN");
G) {
Graphics2D g2 = (Graphics2D) g;
Rectangle.Double leftRectangle = new Rectangle.Double(100, 100, 30, 60);
) . .
____
) . .
}
}
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
74
What is the output of the following code: Circle c1 = new Circle(3);
Circle c2 = c1;
C1)setRadius(4);
System.out.println(c2.getRadius());
A) 4
B) 3
C) 6
D) 8
Circle c2 = c1;
C1)setRadius(4);
System.out.println(c2.getRadius());
A) 4
B) 3
C) 6
D) 8
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
75
What is the output of the following code:
Int num1 = 6;
Int num2 = 10;
num1 = num2;
num2 = num1;
System.out.println(num1 + ", " + num2);
A) 6, 10
B) 10, 6
C) 6, 6
D) 10, 10
Int num1 = 6;
Int num2 = 10;
num1 = num2;
num2 = num1;
System.out.println(num1 + ", " + num2);
A) 6, 10
B) 10, 6
C) 6, 6
D) 10, 10
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
76
What is the nickname for the graphical user interface library in Java?
A) Applet
B) GUI
C) JComponent
D) Swing
A) Applet
B) GUI
C) JComponent
D) Swing
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck