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

What is a method?

A block of code that performs a specific task.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What is a method?

A block of code that performs a specific task.

What is a void method?

A method that performs an action but does not return a value.

What is a non-void method?

A method that performs an action and returns a value.

What is a static method?

A method that belongs to the class itself, not to any specific object.

What is a non-static method?

A method that operates on a specific object.

What is a method signature?

The method name and the parameter list (types and names of inputs).

Define 'parameter'.

Input values that a method can accept to modify its behavior.

What does 'dot notation' refer to?

The way to call methods using the class/object name, a dot, and the method name.

What is the purpose of methods?

To organize code into reusable blocks, making programs more modular and easier to manage.

What is the behavior of a method?

The actions an object can perform.

What are the differences between void and non-void methods?

Void: Performs actions, no return value. Non-void: Performs actions, returns a value.

What are the differences between static and non-static methods?

Static: Belongs to the class, called using class name. Non-static: Belongs to the object, called using object name.

Compare calling static vs. non-static methods.

Static: ClassName.methodName(). Non-static: objectName.methodName(). Static methods don't require an object instance.

What are the differences between parameters and arguments?

Parameters: Variables in method definition. Arguments: Actual values passed when calling the method.

Compare public, private, and protected access modifiers.

Public: Accessible from anywhere. Private: Accessible only within the class. Protected: Accessible within the class, subclass, and package.

Compare System.out.print() and System.out.println().

print(): Prints to the console without a newline. println(): Prints to the console with a newline.

Compare if and switch statements.

if: Evaluates boolean expressions. switch: Evaluates a single variable against multiple constant values.

Compare for and while loops.

for: Used when the number of iterations is known. while: Used when the number of iterations is unknown.

Compare classes and objects.

Classes: Blueprint for creating objects. Objects: Instances of a class.

Compare local and instance variables.

Local: Declared inside a method, scope limited to that method. Instance: Declared inside a class but outside any method, belongs to an object.

How are methods used in real-world software development?

To break down complex tasks into smaller, manageable, and reusable components, improving code organization and maintainability.

Give an example of how static methods are used.

Utility functions like Math.random() or helper methods in a class that don't depend on object state.

How are void methods used in GUI applications?

To handle events like button clicks or menu selections, performing actions without returning a value.

How are non-void methods used in data processing?

To perform calculations or transformations on data and return the result, such as calculating the average of a list of numbers.

How are methods used in game development?

To define the actions and behaviors of game objects, such as moving a character or firing a weapon.

How are methods used in web development?

To handle user input, process data, and generate dynamic content on web pages.

How are methods used in mobile app development?

To implement the functionality of app features, such as displaying data, handling user interactions, and managing device resources.

How are methods used in database management?

To perform operations on database records, such as inserting, updating, deleting, and querying data.

How are methods used in scientific computing?

To implement mathematical algorithms and simulations, such as solving equations or modeling physical phenomena.

How are methods used in machine learning?

To implement machine learning algorithms, such as training models, making predictions, and evaluating performance.