Deck 3: Object-Oriented Programming, Part 1: Using Classes
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/62
Play
Full screen (f)
Deck 3: Object-Oriented Programming, Part 1: Using Classes
1
The automatic conversion from a primitive numeric type to its wrapper class is called:
A) boxing.
B) unboxing.
C) autoboxing.
A) boxing.
B) unboxing.
C) autoboxing.
C
2
The automatic conversion from a numeric wrapper class to the corresponding primitive numeric type is called:
A) boxing.
B) unboxing.
C) autoboxing.
A) boxing.
B) unboxing.
C) autoboxing.
B
3
A way to convert a primitive data type into an object is to use __________ classes.
wrapper
4
In order to test if a character is a digit, we can use the Character class and its ________ method.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
5
The identifier of the object is called the:
A) instance variable.
B) instantiating object.
C) object reference.
D) instance of the class.
A) instance variable.
B) instantiating object.
C) object reference.
D) instance of the class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
6
Object references can refer to any object of its class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
7
What is the relationship between an object and a class?
A) An object is used to debug a class.
B) A class describes a generic template for creating, or instantiating, objects.
C) A class can refer to any object of its object reference.
D) Object diagrams can refer to any object of its class.
A) An object is used to debug a class.
B) A class describes a generic template for creating, or instantiating, objects.
C) A class can refer to any object of its object reference.
D) Object diagrams can refer to any object of its class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
8
DaysOffWork ( ) a default constructor because its parameter list is empty.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
9
The argument list of a constructor consists of a comma-separated list of initial data values to assign to the object.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
10
The mutators are the _______ methods.
A) set
B) get
C) let
D) All of these are correct.
A) set
B) get
C) let
D) All of these are correct.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
11
nextDay ( ) can be used in an expression (the method header is public void nextDay( ) ).
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
12
Java does not provide support for explicitly deleting an object.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
13
Java would generate a compiler error and a run-time error if you attempt to call a method using an object reference whose value is null.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
14
A Scanner object divides its input into sequences of characters called:
A) delimiters.
B) white spaces.
C) tokens.
D) object references.
A) delimiters.
B) white spaces.
C) tokens.
D) object references.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
15
When writing code, you can include two forward slashes for a comment and then later replace them with back slashes to uncomment.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
16
Many of the commonly used classes, such as String and Math, reside in the java.lang package.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
17
indexOf methods are useful for searching a String for a specific String or character.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
18
In which package is the class Math?
A) java.lang
B) java.number
C) java.math
D) java.text
E) java.util
A) java.lang
B) java.number
C) java.math
D) java.text
E) java.util
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
19
Which keyword allows you to use a Java class inside a program?
A) include
B) class
C) import
D) package
E) with
A) include
B) class
C) import
D) package
E) with
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
20
The charAt method returns the character at a particular index in a String.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
21
The constructor for the Random class is:
A) Random ( ).
B) int (Random).
C) nextRandom.
D) nullRandom.
A) Random ( ).
B) int (Random).
C) nextRandom.
D) nullRandom.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
22
Computers are deterministic, so given a specific input to a specific set of instructions, a computer will always produce the same output.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
23
In Math.abs( -5 ), abs is a static method.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
24
The System class is in the java.lang package.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
25
What is the value of the expression Math.sqrt( 4 )?
A) 2.0
B) 0.0
C) 4.0
D) 1.0
A) 2.0
B) 0.0
C) 4.0
D) 1.0
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
26
What is the value of the expression Math.pow( 3, 2 )?
A) 2.0
B) 3.0
C) 6.0
D) 8.0
E) 9.0
A) 2.0
B) 3.0
C) 6.0
D) 8.0
E) 9.0
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
27
We can instantiate an object from the NumberFormat class using the new keyword.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
28
Wrapper classes define an instance variable of a primitive data type and provide useful methods for converting the primitive data types into objects.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
29
In what package is the class Scanner?
A) java.lang
B) java.scanner
C) java.io
D) java.text
E) java.util
A) java.lang
B) java.scanner
C) java.io
D) java.text
E) java.util
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
30
What is the output of this code sequence?
String word = "Java";
System.out.println( word.length( ) );
A) 0
B) 1
C) 4
D) 5
String word = "Java";
System.out.println( word.length( ) );
A) 0
B) 1
C) 4
D) 5
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
31
What is the output of this code sequence?
String word = "Java";
System.out.println( word.charAt( 1 ) );
A) J
B) a
C) v
D) "
String word = "Java";
System.out.println( word.charAt( 1 ) );
A) J
B) a
C) v
D) "
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
32
When an object reference is first declared, its value is null.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
33
Using a null object reference to call a method will not generate an error.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
34
String is in the java.string package.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
35
The length method of the String class takes no argument and returns an int.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
36
The first index of a String is 1.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
37
The DecimalFormat can be used to format a number by specifying a number of digits after the decimal point.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
38
The wrapper class for char is Char.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
39
The _________ class is used to get user input from the Java console.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
40
API stands for __________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
41
The special method called when instantiating an object is a(n) __________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
42
What keyword is used when instantiating an object?
A) Create
B) =
C) new
D) Object
E) is
A) Create
B) =
C) new
D) Object
E) is
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
43
In which package is the class DecimalFormat?
A) java.lang
B) java.number
C) java.format
D) java.text
E) java.util
A) java.lang
B) java.number
C) java.format
D) java.text
E) java.util
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
44
The data type of System.out is:
A) Print.
B) PrintStream.
C) System.
D) Out.
E) IO.
A) Print.
B) PrintStream.
C) System.
D) Out.
E) IO.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
45
In which package is the class NumberFormat?
A) java.lang
B) java.number
C) java.format
D) java.text
E) java.util
A) java.lang
B) java.number
C) java.format
D) java.text
E) java.util
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
46
By convention, method names, instance variables, and object names start with a lowercase letter.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
47
The parameter list of a default constructor is empty.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
48
E and PI are two static data members of the Math class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
49
The accessors are the get methods.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
50
The data associated with an object of a class are called __________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
51
The operations for a class are called __________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
52
The API of class methods has the keyword __________ before the return type.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
53
Java classes are organized in __________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
54
One can generate random numbers using the ___________ class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
55
What are the main benefits of using classes?
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
56
Write a Java statement to import the DecimalFormat class from the appropriate package.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
57
Give one reason you would use the NumberFormat class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
58
What does the following code do?
String s = "Hello";
s = s.toUpperCase( );
String s = "Hello";
s = s.toUpperCase( );
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
59
Identify when you would use nextLine( ) in the Scanner class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
60
Why do you think the String class is in the java.lang package?
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
61
What would you automatically use to assign the char variable to a Character object reference?
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
62
Which methods of the String class would you use to retrieve the user name from an email address whose format is username@provider?
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck