Filters
Question type

Study Flashcards

Methods that retrieve values are called ____ methods.


A) static
B) accessor
C) class
D) mutator

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

Correct Answer

verifed

verified

The ____ method executes first in an application, regardless of where you physically place it within its class.


A) start()
B) run()
C) main()
D) execute()

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

Correct Answer

verifed

verified

What are the four components of a method header?

Correct Answer

verifed

verified

Optional access spec...

View Answer

What is the difference between a mutator method and an accessor method? Provide an example of each.

Correct Answer

verifed

verified

Methods that set or change field values ...

View Answer

An application's main() method must have a void return type.

A) True
B) False

Correct Answer

verifed

verified

Match each term with the correct statement below.

Premises
Method that retrieves a value
Responses
method's signature
dead code
class user
instance variables
static method
data fields
return statement
parameter type
mutator method
header
extended
accessor method
new operator
implementation hiding
formal parameters

Correct Answer

method's signature
dead code
class user
instance variables
static method
data fields
return statement
parameter type
mutator method
header
extended
accessor method
new operator
implementation hiding
formal parameters

public class Employee {    private int empNum;    private double empSalary; ​    public void setEmpNum(int emp)    {       empNum = emp;    }     public void setEmpSalary(double sal)    {       empSalary = sal;    } } Given the class defined in the code above, write the Java statements that will create a new employee instance called employee15 and assign an empNum of 15 and empSalar y of 500.00 to that employee instance.

Correct Answer

verifed

verified

Employee employee15;
employee...

View Answer

Does a programmer need to write every class he or she uses? Why or why not?

Correct Answer

verifed

verified

The same programmer does not need to  wr...

View Answer

Match each term with the correct statement below.

Premises
Unreachable statements that can never execute
Responses
mutator method
formal parameters
method's signature
class user
data fields
dead code
header
extended
accessor method
return statement
instance variables
static method
implementation hiding
parameter type
new operator

Correct Answer

mutator method
formal parameters
method's signature
class user
data fields
dead code
header
extended
accessor method
return statement
instance variables
static method
implementation hiding
parameter type
new operator

Which of the following is NOT an initial value assigned to an object's data field by a default constructor?


A) numeric fields set to 0
B) Boolean fields set to true
C) character fields set to Unicode '\u0000'
D) a field of object references set to null

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

Correct Answer

verifed

verified

Any class can contain an unlimited number of methods.

A) True
B) False

Correct Answer

verifed

verified

Parentheses in a method declaration contain parameters that are "dropped into" the method.

A) True
B) False

Correct Answer

verifed

verified

Access specifiers are sometimes called access____.


A) modifiers
B) bodies
C) initializers
D) declarations

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

Correct Answer

verifed

verified

A method header is also called a(n) _____.


A) argument
B) address
C) statement
D) declaration

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

Correct Answer

verifed

verified

The name of the ____ is always the same as the name of the class whose objects it constructs.


A) method
B) constructor
C) argument
D) variable

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

Correct Answer

verifed

verified

A(n) ____ constructor is one that requires no arguments.


A) class
B) default
C) explicit
D) write

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

Correct Answer

verifed

verified

Every object is a _____ of a more general class.


A) constant
B) member
C) method
D) field

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

Correct Answer

verifed

verified

Methods used with object instantiations are called ____ methods.


A) accessor
B) internal
C) static
D) instance

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

Correct Answer

verifed

verified

How do you use a value returned from a method? Provide an example.

Correct Answer

verifed

verified

If a method returns a value, then when y...

View Answer

Normally, you declare constructors to be ____so that other classes can instantiate objects that belong to the class.


A) reserved
B) private
C) public
D) default

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

Correct Answer

verifed

verified

Showing 41 - 60 of 79

Related Exams

Show Answer