Monday, May 20, 2019

The Papaer Java Test Questions and Answers

Gaddis head start Out With Java 5 From Control Structures to object lenss Chapter 06 A First Look At Classes Multiple prime(prenominal) 1. One or more goals may be created from a(n)_____. a. eye socket b. section c. order d. instance autonomic nervous system B 2. Class objects normally gull _____ that perform useful operations on their data, but primitive variables do non. a. handle b. instances 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. object crystallisees b. severalise objects c. class fields d. field methods autonomic nervous system B 4. A UML diagram does not contain _____. . class have-to doe with b. methods c. fields d. object label autonomic nervous system D 5. An access specifier indicates how the class may be accessed. a. dependable b. glowering autonomic nervous system A 6. Data hiding, which means that critical data stored inside the object is pr otected from code outside the object is accomplished in Java by _____. a. utilise the familiar access specifier on the class methods b. using the snobby access specifier on the class methods c. using the semiprivate access specifier on the class interpretation d. using the private access specifier on the class fields autonomic nervous system D 7. For the adjacent code, which argumentation is not dependable? ublic class Sphere private manifold radius usual double up x private double y private double z a. x is operational to code that is compose outside the Sphere class. b. radius is not available to code written outside the Sphere class. c. radius, x, y, and z be called constituents 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 comprise b. Return typewrite c. annoy specifier d. Parameter variable declaration e. All of the above are parts of the me thod header ANS E 9.A method that stores a value in a classs field or in some other way changes the value of a field is known as a mutator method. a. True b. False ANS A 10. You should not define a class field that is dependent upon the values of other class fields _____. a. in order to avoid having stale data b. because it is trim 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 _____ + set crown(h double) void a. this is a public field called Height and is a double data type b. this is a private method with no parameters and coming backs 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 eliminate a value ANS D 12. Instance methods should be declared static. a. True b. False ANS B 13. Methods that operate on an objects fields are called a. instance variables b. instance methods c. public m ethods d. private methods ANS B 14. The scope of a private instance field is a. the instance methods of the analogous class b. inside the class, but not inside any method c. inside the parentheses of a method header d. the method in which they are defined ANS A 15.A builder is a method that is automatically called when an object is created. a. True b. False ANS A 16. A constructor a. always accepts cardinal arguments b. has return type of void c. has the analogous name as the class d. always has an access specifier of private ANS C 17. Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable. a. True b. False 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 = juvenile Hello, World . str = Hello, World ANS A 19. Two or more methods in a class may have the same name as long as a. they have different return types b. they have different parameter hears c. they have different return types, but the same parameter list d. you cannot have two methods with the same name 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 thump that is divided into three sections. 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. False ANS B 26. For the following code, which statement 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 common practice in object-oriented programming to devise 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 variable 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 password 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, world? A. String str = bare-assed 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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.