Filters
Question type

Study Flashcards

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.

E) A) and D)
F) All of the above

Correct Answer

verifed

verified

A constructor is a method that is automatically called when an object is created.

A) True
B) False

Correct Answer

verifed

verified

True

Instance methods do not have the key word static in their headers.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is NOT involved in finding the classes when developing an object-oriented application?


A) Describe the problem domain.
B) Identify all the nouns.
C) Write the code.
D) Refine the list of nouns to include only those that are relevant to the problem.

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Which of the following are classes from the Java API?


A) Scanner
B) Random
C) PrintWriter
D) All of the above

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

The scope of a private instance field is:


A) the instance methods of the same 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

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.


A) fields
B) instances
C) methods
D) relationships

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

What does the following UML diagram entry mean? + setHeight(h : double) : void


A) this is a public attribute named Height and is a double data type
B) this is a private method with no parameters and returns a double data type
C) this is a private attribute named 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

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

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) 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, y, and z are called members of the Circle class.
D) z is available to code that is written outside the Circle class.

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

Look at the following statement. import java.util.Scanner; This is an example of


A) a wildcard import
B) an explicit import
C) unconditional import
D) conditional import

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

B

Instance methods do not have this key word in their headers:


A) public
B) static
C) private
D) protected

E) All of the above
F) None of the above

Correct Answer

verifed

verified

A UML diagram does not contain:


A) the class name
B) the method names
C) the field names
D) object names

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

A constructor is a method that:


A) returns an object of the class.
B) never receives any arguments.
C) with the name ClassName.constructor.
D) performs initialization or setup operations.

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

Which of the following statements will create a reference, str, to the string, "Hello, world"? (1) String str = new String("Hello, world") ; (2) String str = "Hello, world";


A) 1
B) 2
C) 1 and 2
D) neither 1 or 2

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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 A and B
D) neither A nor B

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

After the header, the body of the method appears inside a set of:


A) brackets, []
B) parentheses, ()
C) braces, {}
D) double quotes, ""

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

One or more objects may be created from a(n) :


A) field
B) class
C) method
D) instance

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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 redundant
C) because it should be defined in another class
D) in order to keep it current

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

False

Showing 1 - 20 of 58

Related Exams

Show Answer