Filters
Question type

Study Flashcards

What will be returned from the method, if the following is the method header? Public Rectangle getRectangle()


A) the address of an object of the Rectangle class
B) the values stored in the data members of the Rectangle object
C) a null value
D) an object that is contained in the class Rectangle

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

Correct Answer

verifed

verified

Enumerated types have this method, which returns the position of an enum constant in the declaration list.


A) position
B) location
C) ordinal
D) index

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

Correct Answer

verifed

verified

An instance of a class does not have to exist in order for values to be stored in a class's static fields.

A) True
B) False

Correct Answer

verifed

verified

If object1 and object2 are objects of the same class, to make object2 a copy of object1


A) write a method for the class that will make a field by field copy of object1 data members into object2 data members.
B) use the copy method that is a part of the Java API.
C) use the default constructor to create object2 with object1 data members.
D) use an assignment statement to make object2 a copy of object1.

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

Correct Answer

verifed

verified

When you make a copy of the aggregate object and of the objects it references,


A) you are performing a shallow copy.
B) you are performing a nested copy.
C) you are performing a deep copy.
D) a compiler error will occur.

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

Correct Answer

verifed

verified

C

The only limitation that static methods have is


A) they must be declared outside of the class.
B) they cannot refer to nonstatic members of the class.
C) they can only be called from static members of the class.
D) they can refer to only nonstatic members of the class.

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

Correct Answer

verifed

verified

Of the following, which would be considered the no-arg constructor for the Rectangle class?


A) public Rectangle(int len, int width)
B) public Rectangle(double len, double width)
C) public Rectangle()
D) All of the above

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

Correct Answer

verifed

verified

C

When a method's return type is an object, what is actually returned to the calling program?


A) a reference to an object of that class
B) only the values in the object that the method accessed
C) an object of that class
D) a null reference

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

Correct Answer

verifed

verified

When an object is passed as an argument, it is actually a reference to the object that is passed.

A) True
B) False

Correct Answer

verifed

verified

When a method in the ________ class returns a reference to a field object, it should return a reference to a copy of the field object to prevent "security holes."


A) aggregate
B) inner
C) String
D) nested

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

Correct Answer

verifed

verified

A method's signature consists of


A) the method name and the parameter list.
B) the return type, the method name, and the parameter list.
C) the size of the method in memory.
D) the return type and the method name.

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

Correct Answer

verifed

verified

A

________ is the term for the relationship created by object aggregation.


A) "Has a"
B) Inner class
C) "Is a"
D) One-to-many

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

Correct Answer

verifed

verified

Assume the class BankAccount has been created, and the following statement correctly creates an instance of the class: BankAccount account = new BankAccount(5000.0) ; What is true about the following statement? System.out.println(account) ;


A) A runtime error will occur.
B) The method will display unreadable binary data on the screen.
C) The account object's toString method will be implicitly called.
D) A compiler error will occur.

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

Correct Answer

verifed

verified

The "has a" relationship is sometimes called a(n) ________ because one object is part of a greater whole.


A) enterprise
B) possession
C) mutual relationship
D) whole-part relationship

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

Correct Answer

verifed

verified

If you have defined a class SavingsAccount with a public static method getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method?


A) account20.getNumberOfAccounts() ;
B) SavingsAccount.getNumberOfAccounts() ;
C) getNumberOfAccounts() ;
D) None of the above

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

Correct Answer

verifed

verified

Look at the following declaration: Enum Tree { OAK, MAPLE, PINE } What is the fully-qualified name of the PINE enum constant?


A) enum.PINE
B) PINE
C) Tree.PINE
D) enum.Tree.PINE

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

Correct Answer

verifed

verified

A class that is defined inside of another class is called a(n)


A) nested class.
B) enumerated class.
C) inner class.
D) helper class.

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

Correct Answer

verifed

verified

enum constants have a toString method.

A) True
B) False

Correct Answer

verifed

verified

You can declare an enumerated data type inside of a method.

A) True
B) False

Correct Answer

verifed

verified

You can use the enum key word to


A) create your own data type.
B) specify the values that belong to that type.
C) Both A and B
D) Neither A nor B

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

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer