Java Ch. 6 Quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

a. String

After the header, the body of the method appears inside a set of: a. braces, {} b. double quotes, "" c. brackets, [] d. parentheses, ()

a. braces, {}

One or more objects may be created from a(n): a. class b. instance c. field d. method

a. class

Most programming languages that are in use today are: a. object-oriented b. logic c. functional d. procedural

a. object-oriented

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.

a. y is available to code that is written outside the Circle class.

Look at the following statement. import java.util.Scanner; This is an example of a. unconditional import b. an explicit import c. conditional import d. a wildcard import

b. an explicit import

In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top section has the ________; the middle section holds ________; the bottom section holds ________. a. object name; attributes or fields; methods b. class name; attributes or fields; methods c. object name; methods; attributes or fields d. class name; object name; methods

b. class name; attributes or fields; methods

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

b. fields; methods

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

b. has the same name as the class

Quite often you have to use this statement to make a group of classes available to a program. a. assume b. import c. link d. use

b. import

Another term for an object of a class is: a. method b. instance c. access specifier d. member

b. instance

Methods that operate on an object's fields are called: a. instance variables b. instance methods c. private methods d. public methods

b. instance methods

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. a. instances b. methods c. relationships d. fields

b. methods

In UML diagrams, this symbol indicates that a member is public. a. - b. / c. + d. @

c. +

In UML diagrams, this symbol indicates that a member is private: a. * b. + c. - d. #

c. -

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; } public double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } } public class CustomerOrder { Order order; int orderNumber = 1234; double orderAmt = 580.00; double orderDisc = .1; order = new Order (orderNumber, orderAmt, orderDisc); double finalAmount = order.finalOrderTotal(); System.out.printf("Final order amount = $%,.2f\n", finalAmount); a. 528.00 b. 580.00 c. 522.00 d. There is no value because the object order has not been created.

c. 522.00

Look at the following statement. import java.util.*; This is an example of: a. unconditional import b. conditional import c. a wildcard import d. an explicit import

c. a wildcard import

A class's responsibilities include: a. the things a class is responsible for doing b. the things a class is responsible for knowing c. both the things a class is responsible for doing and the things a class is responsible for knowing d. neither the things a class is responsible for doing nor the things a class is responsible for knowing

c. both the things a class is responsible for doing and the things a class is responsible for knowing

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

c. class; objects

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

c. have the same name, but different parameter lists

The following package is automatically imported into all Java programs. a. java.default b. java.util c. java.lang d. java.java

c. java.lang

A UML diagram does not contain: a. the method names b. the class name c. object names d. the field names

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

c. the variable name followed by a colon and the data type

For the following code, which statement is NOT true? public class Sphere { private double radius; public double x; private double y; private double z; } a. radius is not available to code written outside the Circle class. b. radius, x, y, and z are called members of the Circle class. c. z is available to code that is written outside the Circle class. d. x is available to code that is written outside the Circle class.

c. z is available to code that is written outside the Circle class.

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; } public int getOrderAmount() { return orderAmount; } public int getOrderDisc() { return orderDisc; } } 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.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.

d. There is no value because the object order has not been created.

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

d. fields private

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.

d. performs initialization or setup operations.

Instance methods do not have this key word in their headers: a. private b. public c. protected d. static

d. static

The scope of a public instance field is: a. inside the class, but not inside any method b. only the class in which it is defined c. inside the parentheses of a method header d. the instance methods and methods outside the class

d. the instance methods and methods outside the class

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

d. using the private access specifier on the class fields


Kaugnay na mga set ng pag-aaral

Ch. 18: Performance & Discharge & Ch. 19: Breach of Contract & Remedies

View Set

Chapter 35 Ownership Of A Corporation Ashcroft Law for Business

View Set

Federal Government Unit Two Exam Chapter 6-10

View Set

PEDs Chapt 26 Nursing Care of the Child with an Immunologic Disorder

View Set

13.1.4 - Practice Questions, 16.1.8 - Practice Questions, 16.2.5 - Practice Questions, 15.8.4 - Practice Questions, 15.7.4 - Practice Questions, 15.6.8 - Practice Questions, 15.5.7 - Practice Questions, 14.3.9 - Practice Questions, 15.1.4 - Practice...

View Set

Test 3 - Chapter 11 - Vaccination

View Set