Deck 5: Defining Classes Ii
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/46
Play
Full screen (f)
Deck 5: Defining Classes Ii
1
A copy constructor has _________ parameters.
(a)zero
(b)one
(c)two
(d)three
(a)zero
(b)one
(c)two
(d)three
B
2
All of these are methods of Java's Math class except:
(a)pow
(b)min
(c)random
(d)toString
(a)pow
(b)min
(c)random
(d)toString
D
3
The program included in the Java SDK that allows a programmer to separate the class interface from the class implementation is called:
(a)javac
(b)java
(c)javadoc
(d)none of the above
(a)javac
(b)java
(c)javadoc
(d)none of the above
C
4
A class that contains public methods that can change the data in the object of a class is called a/an:
(a)mutable class
(b)immutable class
(c)invariant class
(d)none of the above
(a)mutable class
(b)immutable class
(c)invariant class
(d)none of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
5
The method trim of the String class trims off:
(a)Leading white space
(b)Trailing white space
(c)Leading and trailing white space
(d)Blanks
(a)Leading white space
(b)Trailing white space
(c)Leading and trailing white space
(d)Blanks
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
6
To create a package,you must add a package statement at the ____________ of each class file.
(a)beginning
(b)end
(c)before each method signature
(d)after the import statements
(a)beginning
(b)end
(c)before each method signature
(d)after the import statements
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
7
The Math method that returns the nearest whole number that is greater than or equal to its argument is:
(a)round
(b)ceil
(c)floor
(d)all of the above
(a)round
(b)ceil
(c)floor
(d)all of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
8
A main method can be placed inside a class definition.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
9
In a static method,you may use the this parameter either explicitly or implicitly.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
10
An example of secondary memory is:
(a)RAM
(b)ROM
(c)hard disk
(d)all of the above
(a)RAM
(b)ROM
(c)hard disk
(d)all of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
11
Static variables are often used:
(a)in arithmetic expressions
(b)to communicate between objects
(c)within looping structures
(d)all of the above
(a)in arithmetic expressions
(b)to communicate between objects
(c)within looping structures
(d)all of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
12
A condition that allows a programmer to circumvent the private modifier and change the private instance variable is called:
(a)a copy constructor
(b)a privacy leak
(c)a class invariant
(d)an anonymous object
(a)a copy constructor
(b)a privacy leak
(c)a class invariant
(d)an anonymous object
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
13
Javadoc requires a comment to be delimited by _________ to be included in the extracted class interface.
(a)// //
(b)/* */
(c)/** */
(d)" "
(a)// //
(b)/* */
(c)/** */
(d)" "
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
14
The conversion from an object of a wrapper class to a value of its associated primitive type is called:
(a)Boxing
(b)Unboxing
(c)Converting
(d)Reinstantiating
(a)Boxing
(b)Unboxing
(c)Converting
(d)Reinstantiating
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
15
null can be used:
(a)to indicate a variable has no real value
(b)in a Boolean expression with ==
(c)as a placeholder
(d)all of the above
(a)to indicate a variable has no real value
(b)in a Boolean expression with ==
(c)as a placeholder
(d)all of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
16
When you use the assignment operator with variables of a class type,you are assigning a:
(a)value
(b)primitive type
(c)local variable
(d)reference
(a)value
(b)primitive type
(c)local variable
(d)reference
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
17
A static method is one that can be used with a _____________.
(a)instance variable
(b)local variable
(c)global variable
(d)the class name as a calling object
(a)instance variable
(b)local variable
(c)global variable
(d)the class name as a calling object
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
18
Converting from a value of primitive type to a corresponding object of its associated wrapper class is called:
(a)Boxing
(b)Unboxing
(c)Converting
(d)Reinstantiating
(a)Boxing
(b)Unboxing
(c)Converting
(d)Reinstantiating
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
19
All of the following are wrapper classes except:
(a)String
(b)Integer
(c)Character
(d)Double
(a)String
(b)Integer
(c)Character
(d)Double
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
20
Only ______ copy/copies of a static variable are available to objects of a class.
(a)one
(b)two
(c)three
(d)none of the above
(a)one
(b)two
(c)three
(d)none of the above
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
21
Write a Java method that returns true if and only if a character is a digit or a letter.The method should display appropriate feedback to the console.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
22
Primitive types are reference types.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
23
Write ONE Java statement that computes and displays a random number between 1 and 25.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
24
Write a statement that creates and initializes a static variable named salesTax to 7.59.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
25
Deprecated methods should be used in new Java code.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
26
You should avoid the use of null as an argument to a method.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
27
Write a statement that creates a constant variable named TAX_RATE.The tax rate is 8.25%.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
28
A class invariant is a statement that is always true for every object of the class.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
29
How many bytes are contained within 16-bits,32-bits,64-bits?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
30
Wrapper classes provide a class type corresponding to each of the primitive types so that you can have class types that behave somewhat like primitive types.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
31
Explain in detail how main memory works.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
32
You may use methods of the Math class without an import statement.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
33
Wrapper classes are provided for all primitive Java types except Boolean.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
34
To use a package,the program must contain an import statement that names the package.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
35
A bit may have the value of either a 1 or 0.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
36
Write ONE Java statement that computes and displays the value of 25.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
37
When used with objects,what is the equality ( == )operator really comparing?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
38
The String class is a mutable class.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
39
Define boxing and unboxing.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
40
All versions of Java support automatic boxing.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
41
Does an object created with a copy constructor reference the same memory location that the original object references? Explain.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
42
Add accessor and mutator methods to the Book class created in question #13.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
43
Explain how a package is named in Java.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
44
Create a Java class named Book with instance variables title,author,ISBN,and yearPublished.Include javadoc style comments to describe your interface.Such a class would normally have methods,but you are not required to supply any methods.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
45
Add a constructor and a copy constructor to the Book class created in question #13.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
46
What is the purpose of Java's wrapper classes?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck