Exam 3: Using Methods Classes and Objects

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Describe fully qualified identifiers and explain why they are necessary.

Free
(Essay)
4.8/5
(39)
Correct Answer:
Verified

A complete name that includes the class is a fully qualified identifier. If you want to use a method in another class, the compiler does not recognize the method unless you use the full name. A fully qualified identifier includes the class time, a dot, and the method name.

Often, programmers list the ____________________ first because it is the first method used when an object is created.

Free
(Short Answer)
4.8/5
(38)
Correct Answer:
Verified

constructor

public int getStudentNum() { return studentNum; } In the above code, identify if the method is a mutator method or an accessor method. Describe how the two types of methods differ and how they are similar.

Free
(Essay)
4.8/5
(44)
Correct Answer:
Verified

Methods that set or change field values are called mutator methods; methods that retrieve
values are called accessor methods. In Java, mutator methods conventionally start with the
prefix set , and accessor methods conventionally start with the prefix get . Using these three-letter prefixes with your method names is not required, but it is conventional.
The method in the above code is an accessor method because it retrieves studentNum.

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

(Essay)
4.7/5
(39)

After an object has been instantiated, its methods can be accessed using the object's _____, a dot, and a method call.

(Multiple Choice)
4.7/5
(34)

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

(True/False)
4.9/5
(39)

What is a method and how is one used?

(Essay)
4.9/5
(36)

public Employee() { empSalary = 300.00; } The above code shows the Employee class constructor. What is a constructor and how would this default constructor operate?

(Essay)
4.8/5
(40)

In order to allocate the needed memory for an object, you must use the ____ operator.

(Multiple Choice)
4.9/5
(38)

public static void predictRaise(double salary) { double newSalary; final double RAISE_RATE = 1.10; newSalary = salary * RAISE_RATE; System.out.println("Current salary: " + salary + " After raise: " + newSalary); } In the above code, what are the parameter data type and parameter identifier? How do you identify each?

(Essay)
4.9/5
(35)

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

(Multiple Choice)
4.9/5
(42)

How does the order in which methods appear in a class affect how the application executes? Please explain.

(Essay)
4.9/5
(40)

When an application is run, the method that must be executed first must be named ____.

(Multiple Choice)
4.7/5
(43)

A major advantage of a method is that it is easily reusable. What does it mean to reuse a method and what are the advantages of doing so?

(Essay)
4.8/5
(27)

Any class can contain an unlimited number of methods.

(True/False)
4.8/5
(45)

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

(Essay)
4.9/5
(32)

Data items you use in a call to a method are called ____.

(Multiple Choice)
4.9/5
(40)

  In the above code, the calculateBonus() method acts as a black box. What does this mean? In the above code, the calculateBonus() method acts as a "black box." What does this mean?

(Essay)
4.9/5
(41)

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

(Short Answer)
4.8/5
(41)

Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class.

(Multiple Choice)
4.9/5
(42)
Showing 1 - 20 of 66
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)