









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










โ It is common practice in object-oriented programming to make all of a class's: a. fields and methods public b. fields public c. methods private d. fields private. Answer: d. fields private โ Methods that operate on an object's fields are called: a. instance variables b. instance methods c. private methods d. public methods. Answer: b. instance methods
โ Java allows you to create objects of this class in the same way you would create primitive variables. a. String b. Scanner c. PrintWriter d. Random. Answer: a. String โ Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by: a. using the public access specifier on the class methods b. using the private access specifier on the class methods c. using the private access specifier on the class definition d. using the private access specifier on the class fields. Answer: d. using the private access specifier on the class fields โ For the following code, which statement is NOT true? public class Sphere { private double radius; public double x;
a. unconditional import b. an explicit import c. conditional import d. a wildcard import. Answer: b. an explicit import โ In UML diagrams, this symbol indicates that a member is private: a. * b. + c. - d. #. Answer: c. - โ Another term for an object of a class is: a. method b. instance c. access specifier d. member. Answer: b. instance
โ For the following code, which statement is NOT true? public class Circle { private double radius; public double x; private double y; } a. y is available to code that is written outside the Circle class. b. radius is not available to code written outside the Circle class. c. radius, x, and y are called members of the Circle class. d. x is available to code that is written outside the Circle class.. Answer: a. y is available to code that is written outside the Circle class. โ Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. a. instances b. methods c. relationships d. fields. Answer: b. methods
a. unconditional import b. conditional import c. a wildcard import d. an explicit import. Answer: c. a wildcard import โ In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies. a. attribute; methods b. class; fields c. class; objects d. object; classes. Answer: c. class; objects โ A UML diagram does not contain: a. the method names b. the class name c. object names d. the field names. Answer: c. object names
โ In a UML diagram to indicate the data type of a variable enter: a. the class name followed by the variable name followed by the data type b. the data type followed by the variable name c. the variable name followed by a colon and the data type d. the variable name followed by the data type. Answer: c. the variable name followed by a colon and the data type โ Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum; private double orderAmount; private double orderDiscount; public Order (int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; }
d. There is no value because the object order has not been created.. Answer: c. 522. โ One or more objects may be created from a(n): a. class b. instance c. field d. method. Answer: a. class โ A constructor is a method that: a. never receives any arguments. b. returns an object of the class. c. with the name ClassName.constructor. d. performs initialization or setup operations.. Answer: d. performs initialization or setup operations. โ Most programming languages that are in use today are: a. object-oriented b. logic
c. functional d. procedural. Answer: a. object-oriented โ A class specifies the ________ and ________ that a particular type of object has. a. fields; object names b. fields; methods c. relationships; methods d. relationships; object names. Answer: b. fields; methods โ Instance methods do not have this key word in their headers: a. private b. public c. protected d. static. Answer: d. static โ Given the following code, what will be the value of finalAmount when it is displayed?
public class CustomerOrder { public static void main(String[] args) { int ordNum = 1234; double ordAmount = 580.00; double discountPer = .1; Order order; double finalAmount = order.getOrderAmount() - order.getOrderAmount() * order.getOrderDisc(); System.out.printf("Final order amount = $%,.2f\n", finalAmount); } } a. 528. b. 580. c. There is no value because the constructor has an error. d. There is no value because the object order has not been created.. Answer: d. There is no value because the object order has not been created.
โ Overloading means multiple methods in the same class: a. have the same name, but different return types b. have different names, but the same parameter list c. have the same name, but different parameter lists d. perform the same function. Answer: c. have the same name, but different parameter lists โ A constructor: a. always has an access specifier of private b. has the same name as the class c. always accepts two arguments d. has return type of void. Answer: b. has the same name as the class โ The following package is automatically imported into all Java programs. a. java.default b. java.util c. java.lang