Java Foundations 3rd Edition By John Lewis-Test Bank
Format: Downloadable ZIP File
Resource Type: Test bank
Duration: Unlimited downloads
Delivery: Instant Download
Test Bank For Java Foundations 3rd Edition By John Lewis
ISBN-10:0133370461 , ISBN-13:978-0133370461
Chapter 3: Utilizing Lessons and Objects
A number of Selection Questions:
1) The ________________ operator is used to instantiate an object.
a) static
b) new
c) +
d) –
e) not one of the above
Reply: b
Clarification: The brand new operator instantiates an object. There isn’t a static operator, and the + and – operators are for arithmetic expressions (though the + operator may also be used for String concatenation).
2) A particular methodology that’s invoked to arrange an object throughout instantiation is named a ___________________.
a) new methodology
b) dot operator
c) creator
d) constructor
e) destructor
Reply: d
Clarification: The constructor is named to arrange an object throughout instantiation. The dot operator is used to entry strategies of an object. There isn’t a “new” methodology – new is an operator. Java additionally doesn’t have “creators” or “destructors.”
3) Which of the next is an invalid approach to instantiate a String object?
a) String title = new String(“Java Software program Options”);
b) String identify = “John Lewis”;
c) String empty = “”;
d) String alsoEmpty = new String(“”);
e) the entire above are legitimate
Reply: e
Clarification: Decisions a and d symbolize the usual method to instantiating a String object. Selection d creates the emptry string. Decisions b and c use a shortcut notation that’s solely accessible for making a String object.
4) Assume that we’ve a Random object referenced by a variable referred to as generator. Which of the next strains will generate a random quantity within the vary 5-20 and retailer it within the int variable randNum?
a) randNum = generator.nextInt(15) + 5;
b) randNum = generator.nextInt(15) + 6;
c) randNum = generator.nextInt(16) + 5;
d) randNum = generator.nextInt(16) + 6;
e) not one of the above
Reply: c
Clarification: When referred to as with 16 as a parameter, the nextInt() methodology will return a quantity within the vary 0 to fifteen. Including 5 to this random quantity will generate a quantity within the vary 5 to twenty.
5) Which of the next courses embrace the getCurrencyInstance() methodology?
a) String
b) NumberFormat
c) DecimalFormat
d) Math
e) not one of the above
Reply: b
Clarification: The NumberFormat class consists of the getCurrencyInstance() methodology.
6) Which of the next expressions appropriately compute 5 + 26?
a) end result = 5 + 2^6;
b) end result = 5 + 2*exponent(6);
c) end result = 5 + 2*Math.exponent(6);
d) end result = 5 + Math.pow(2, 6);
e) not one of the above
Reply: d
Clarification: Selection a is incorrect as a result of Java doesn’t have an exponential operator for primitive sorts. Decisions b and C are incorrect as a result of there are not any strategies named exponent within the java.lang package deal or the Math class. Selection c appropriately makes use of the Math.pow methodology to compute the expression.
7) Take into account the next snippet of code:
Random generator = new Random();
int randNum = generator.nextInt(20) + 1;
Which of the next might be true after these strains are executed?
a) randNum will maintain a quantity between 1 and 20 inclusive.
b) randNum will maintain a quantity between 0 and 20 inclusive.
c) randNum will maintain a quantity between 1 and 21 inclusive.
d) these strains is not going to be executed as a result of a compiler error will end result.
e) not one of the above
Reply: a
Clarification: When referred to as with a parameter of 20, the nextInt() methodology will return an integer between 0 and 19 inclusive. Including one to this can lead to a quantity between 1 and 20 inclusive.
8) Which of the next represents the right approach to create a NumberFormat object that codecs numbers as percentages?
a) NumberFormat fmt = new NumberFormat(%);
b) NumberFormat fmt = new NumberFormat(“%”);
c) NumberFormat fmt = NumberFormat.getPercentInstance();
d) NumberFormat fmt = new PercentNumberFormat();
e) not one of the above
Reply: c
Clarification: The NumberFormat class makes use of manufacturing unit strategies to assemble objects. The brand new operator is named implicitly on this case. The manufacturing unit methodology that’s used is named getPercentInstance(). Due to this fact selection c is appropriate. Selection a and Selection b are incorrect since they name the brand new operator explicitly. Selection d is inaccurate as a result of there isn’t a PercentNumberFormat class that may be referred to as with the brand new constructor.
9) Which of the next is an accurate declaration of enumerated sort for the fits of a deck of playing cards?
a) enumerated sort Swimsuit = { hearts, spades, diamonds, golf equipment };
b) enum Swimsuit {hearts, spades, diamonds, golf equipment };
c) enum Swimsuit {hearts, spades, diamonds, golf equipment }
d) enumerated sort Swimsuit = {hearts, spades, diamonds, golf equipment };
e) enum Swimsuit = { hearts, spades, diamonds, golf equipment }
Reply: c
Clarification: Selection c represents the proper syntax for declaring an enumerated sort referred to as Swimsuit that may take one of many values hearts, spades, diamonds or golf equipment.
10) ____________________ is the automated conversion between a primitive worth and a corresponding wrapper object.
a) Producing
b) Aliasing
c) Quantity formatting
d) Static invocation
e) Autoboxing
Reply: e
Clarification: Autoboxing permits a programmer to mechanically convert between a primitive worth and a corresponding wrapper object. The opposite 4 solutions are incorrect.
Textsbook Associated Test Banks
Test Bank For Investment Analysis And Management 12th Edition B Charles
Test Bank For Investments Analysis And Management 3rd Canadian Edition By W. Sean Cleary
User Reviews
Be the first to review “Java Foundations 3rd Edition By John Lewis-Test Bank”
Original price was: $35.00.$24.97Current price is: $24.97.
There are no reviews yet.