zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion Bank

What are the general steps to write a method?

  1. Define access modifier. 2. Define return type. 3. Name the method. 4. Define parameters (if any). 5. Write the method body.
Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What are the general steps to write a method?

  1. Define access modifier. 2. Define return type. 3. Name the method. 4. Define parameters (if any). 5. Write the method body.

What are the steps to submit an assignment?

  1. Grade the assignment. 2. Increment assignmentsComplete. 3. If grade is correct, increment correctAssignments.

How does pass-by-value affect primitive variables?

Changes to the parameter inside the method do not affect the original variable outside the method.

How does pass-by-value affect reference variables?

Changing the object's state (e.g., using a setter) inside the method affects the original object outside the method.

What is the general format of a method header in Java?

()

Why should mutable objects passed as parameters be handled carefully?

Modifications within the method can unintentionally alter the object's state outside the method.

What determines a method's accessibility?

The access modifier (public, private, protected) used in the method header.

What is the role of parameters in a method?

To receive input values that the method uses during its execution.

What is the significance of the return type in a method?

It specifies the data type of the value that the method returns to the caller.

What does the @Override annotation indicate?

That a method in a subclass is overriding a method from its superclass.

What are the common access modifiers in Java?

public, private, and protected.

What is the purpose of Javadoc comments?

To document the purpose, parameters, and return values of methods for API documentation.

What is pass-by-value?

A method receives a copy of the variable's value; changes inside the method do not affect the original variable outside.

What is a reference variable?

A variable that stores the memory address of an object.

What is an access modifier?

Keywords in Java that control the visibility and accessibility of classes, methods, and variables.

What is the return type of a method?

The data type of the value that a method returns after its execution.

What is a parameter in a method?

A variable that receives a value passed into a method.

What is a method header?

The first line of a method definition, including access modifier, return type, method name, and parameters.

What is a mutable object?

An object whose state can be modified after it is created.

What is a getter method?

A method used to retrieve the value of an object's attribute.

What is an instance variable?

A variable defined in a class for which every object of the class has its own copy.

What is the purpose of the 'void' return type?

Indicates that the method does not return any value.