Filters
Question type

Study Flashcards

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


A) first()
B) void()
C) main()
D) final()

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

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

constructor

Any class can contain an unlimited number of methods.

A) True
B) False

Correct Answer

verifed

verified

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.

Correct Answer

verifed

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.

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

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

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) All of the above
F) None of the above

Correct Answer

verifed

verified

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

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


A) saved
B) extended
C) copied
D) used

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

Correct Answer

verifed

verified

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


A) new
B) main
C) type
D) return

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

Correct Answer

verifed

verified

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


A) arguments
B) instance variables
C) method declarations
D) headers

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

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

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

Correct Answer

verifed

verified

The order in which methods appear in a c...

View Answer

  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?

Correct Answer

verifed

verified

The predictRaise method calls the calcul...

View Answer

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


A) identifier
B) class
C) operator
D) output

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

Correct Answer

verifed

verified

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?

Correct Answer

verifed

verified

When you write the method declaration fo...

View Answer

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

Correct Answer

verifed

verified

A constructor establishes an object. A d...

View Answer

What is a method and how is one used?

Correct Answer

verifed

verified

A method is a program module that contai...

View Answer

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?

Correct Answer

verifed

verified

After a method is created, you...

View Answer

Describe fully qualified identifiers and explain why they are necessary.

Correct Answer

verifed

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.

Showing 1 - 20 of 66

Related Exams

Show Answer