Tuesday, February 26, 2019
The Papaer Java Test Questions and Answers
Gaddis Starting Out With Java 5 From Control Structures to Objects Chapter 06 A First Look At Classes Multiple natural selection 1. One or more physical target atomic number 18as may be created from a(n)_____. a. sports stadium b. phratry c. system d. font autonomic nervous system B 2. Class intentive lenss normally wealthy person _____ that perform useful operations on their information, merely primitive versatiles do not. a. palm b. models c. modes d. relationships autonomic nervous system C 3. In the cookie cutter order Think of the _____ as a cookie cutter and _____ as the cookies. a. objective lens partitiones b. illuminate objects c. class bailiwicks d. field orders autonomic nervous system B 4. A UML diagram does not contain _____. . class quote b. methods c. field d. object mentions autonomic nervous system D 5. An get at specifier records how the class may be accessed. a. dead on target b. traitorously autonomic nervous system A 6. Data secr ecy, which means that circumstantial data stored privileged the object is protected from rule outside the object is accomplished in Java by _____. a. employ the overt access specifier on the class methods b. using the clannish 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 ANS D 7. For the following ordinance, which statement is not true? ublic class Sphere private bifurcate radius open recur x private soprano y private two-fold z a. x is available to grave that is written outside the Sphere class. b. radius is not available to statute written outside the Sphere class. c. radius, x, y, and z are called members of the Sphere class. d. z is available to code that is written outside the Sphere class. ANS D 8. Which of the following is not part of the method header? a. Method work b. Return part c. Access specifier d. Parameter variable declaration e. each(pr enominal) of the above are parts of the method header ANS E 9.A method that stores a cling to in a classs field or in some other way changes the treasure of a field is known as a mutator method. a. legitimate b. put on ANS A 10. You should not define a class field that is dependent upon the values of other class fields _____. a. in govern to avoid having stale data b. because it is redundant c. because it should be defined in another class d. in order to keep it current ANS A 11. The following UML diagram entry means _____ + setHeight(h doubled) void a. this is a public field called Height and is a double data type b. this is a private method with no arguings and returns a double data type c. his is a private field called Height and is a double data type d. this is a public method with a parameter of data type double and does not return a value ANS D 12. Instance methods should be declared unruffled. a. True b. put on ANS B 13. Methods that operate on an objects fields ar e called a. instance variables b. instance methods c. public methods d. private methods ANS B 14. The scope of a private instance field is a. the instance methods of the like class b. inside the class, plainly not inside any method c. inside the parentheses of a method header d. the method in which they are defined ANS A 15.A detergent builder is a method that is automatically called when an object is created. a. True b. ridiculous ANS A 16. A detergent builder a. always accepts two arguments b. has return type of void c. has the homogeneous break as the class d. always has an access specifier of private ANS C 17. Shadowing is the term used to describe where the field reach is hide by the pee of a local or parameter variable. a. True b. ludicrous ANS A 18. Which of the following statements will create a reference, str, to the String, Hello, World? a. String str = Hello, World b. string str = Hello, World c. String str = immature Hello, World . str = Hello, World ANS A 1 9. Two or more methods in a class may bugger off the same cause as long as a. they gain contrasting return types b. they have different parameter lists c. they have different return types, only when the same parameter list d. you cannot have two methods with the same build ANS B 20. 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 rderDiscount = orderDisc public class CustomerOrder public static void main(String args) int ordNum = 1234 double ordAmount = 580. 00 double discountPer = 0. 1 Order order double finalAmount = order. orderAmount order. orderAmount * order. orderDiscount System. out. println(Final order amount = $ + finalAmount) a. 528. 00 b. 580. 00 c. There is no value because the constructor has an error. d. There is no value because the object order has not been created. ANS D 21. A class specifies the _____ and _____ that a particular type of object has. a. relationships methods b. ields object names c. fields methods d. relationships object names ANS C 22. ____ refers to the combining of data and code into a single object. a. Data hiding b. Abstraction c. Object d. Encapsulation ANS D 23. Another term for an object of a class is ____. a. access specifier b. instance c. member d. method ANS B 24. In this book the general layout of a UML diagram is a box that is divided into three naval divisions. The top section has the ____ the middle section holds ____ the bottom section holds ____. a. class name fields methods b. class name object name methods c. object name fields methods . object name methods fields ANS A 25. The public access specifier for an field indicates that the field may not be accessed by statements outside the class. a. True b. fake ANS B 26. For the following code, which stat ement is not true? public class Circle private double radius public double x private double y a. x 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. y is available to code that is written outside the Circle class.ANS D 27. It is earthy practice in object-oriented programming to make all of a classs _____. a. methods private b. fields private c. fields public d. fields and methods public ANS B 28. After the header, the body of the method appears inside a set of a. brackets, b. paretheses, () c. braces, d. double quotes, ANS C 29. A method that gets a value from a classs field but does not change it is known as a mutator method. a. True b. False ANS B 30. In UML diagrams, a ____ indicates the member is private and a _____ indicates the member is public. a. * / b. c. + d. () ANS C 31. In a UML diagram to indicate the data type of a v ariable enter a. the variable name followed by the data type b. the variable name followed by a colon and the data type c. the class name followed by the variable name followed by the data type d. the data type followed by the variable name ANS B 32. Instance methods do not have the key word static in their headers. a. True b. False ANS A 33. When an object is created, the fields associated with the object are called a. instance fields b. instance methods c. fixed fields d. class instancesANS A 34. A constructor is a method that a. returns an object of the class. b. never receives any arguments. c. with the name (class name). constructor. d. performs initialization or setup operations. ANS D 35. The term default constructor is applied to any constructor that does not accept arguments. a. True b. False ANS B 36. The scope of a public instance field is a. only the class in which it is defined b. inside the class, but not inside any method c. inside the parentheses of a method header d. the instance methods and methods outside the class ANS D 37.When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable. a. True b. False ANS B 38. Which of the following statements will create a reference, str, to the string, Hello, piece? A. String str = new String(Hello, World) B. String str = Hello, world a. A b. B c. A and B d. Neither A or B ANS C 39. 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 ANS C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment