AP Computer Science a Flashcards: Calling Class Methods

Study Calling Class Methods in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

AP Computer Science a

Calling Class Methods

0 mastered0 still learning

0% Complete

QUESTION
1/ 45

Can a static method call another static method?

Tap card or press Space to flip

ANSWER

Yes, it can. Static methods can invoke other static methods directly.

How well did you know it?

Card 1 / 45

What this deck covers

This deck focuses on Calling Class Methods, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

All flashcards

Flashcard 1: Can a static method call another static method?

Answer: Yes, it can. Static methods can invoke other static methods directly.

Flashcard 2: How do you call a static method from a different package?

Answer: Import the class, then call ClassName.methodName();. Import statement provides access to external classes.

Flashcard 3: What is the result of calling a non-static method using the class name?

Answer: Compilation error. Non-static methods require an instance to be called.

Flashcard 4: What happens if you call a static method with a null reference?

Answer: No error; static method is called on class. Static methods belong to class, not instance.

Flashcard 5: Which method is called automatically when a Java program starts?

Answer: main method. Entry point for Java program execution.

Flashcard 6: State the syntax for calling a static method in Java.

Answer: ClassName.methodName();. Standard format for accessing class-level methods.

Flashcard 7: Can a static method be abstract?

Answer: No, it cannot. Abstract requires overriding, but static prevents inheritance.

Flashcard 8: Can static methods access instance variables directly?

Answer: No, they cannot. Instance variables belong to objects, not the class.

Flashcard 9: How do you call a static method from a class?

Answer: ClassName.methodName();. Uses dot notation with class name, no object needed.

Flashcard 10: How do you call a static method from a different package?

Answer: Import the class, then call ClassName.methodName();. Import statement provides access to external classes.

Flashcard 11: Identify the error: public void static print() {}

Answer: Incorrect order; should be public static void print() {}. Modifiers must follow specific order: access, static, return.

Flashcard 12: What type of methods can be called without creating an object?

Answer: Static methods. Class methods don't require object instantiation.

Flashcard 13: Identify the error: static void display() { this.show(); }

Answer: Cannot use 'this' in a static method. 'this' refers to instance, not available in static context.

Flashcard 14: Can a static method access a static variable?

Answer: Yes, it can. Static methods can access other static members.

Flashcard 15: Can a static method call a non-static method directly?

Answer: No, it cannot. Static context cannot access instance methods directly.

Flashcard 16: What keyword is used to define a class method?

Answer: static. Makes method belong to class rather than instances.

Flashcard 17: How do you call a static method from a class?

Answer: ClassName.methodName();. Uses dot notation with class name, no object needed.

Flashcard 18: Can static methods be overridden?

Answer: No, they can be hidden but not overridden. Static methods are resolved at compile-time, not runtime.

Flashcard 19: What keyword is used to define a class method?

Answer: static. Makes method belong to class rather than instances.

Flashcard 20: Identify the error: public void static print() {}

Answer: Incorrect order; should be public static void print() {}. Modifiers must follow specific order: access, static, return.

Flashcard 21: What type of methods can be called without creating an object?

Answer: Static methods. Class methods don't require object instantiation.

Flashcard 22: What is the result of calling a non-static method using the class name?

Answer: Compilation error. Non-static methods require an instance to be called.

Flashcard 23: How do you call the main method of another class?

Answer: OtherClass.main(args);. Main method is static, so use class name to call.

Flashcard 24: Can a static method be overloaded?

Answer: Yes, it can. Multiple static methods can have same name, different parameters.

Flashcard 25: State the syntax for calling a static method in Java.

Answer: ClassName.methodName();. Standard format for accessing class-level methods.

Flashcard 26: How do you call the main method of another class?

Answer: OtherClass.main(args);. Main method is static, so use class name to call.

Flashcard 27: Which method is called automatically when a Java program starts?

Answer: main method. Entry point for Java program execution.

Flashcard 28: Can a static method have a return type?

Answer: Yes, it can. Static methods can return values like any method.

Flashcard 29: Identify the error: static int calculate() return 0;

Answer: Missing curly braces. Method body requires braces around statements.

Flashcard 30: Can a static method call a non-static method directly?

Answer: No, it cannot. Static context cannot access instance methods directly.

Flashcard 31: What is the signature of the main method in Java?

Answer: public static void main(String[] args). Required format for Java application entry point.

Flashcard 32: Can a static method be abstract?

Answer: No, it cannot. Abstract requires overriding, but static prevents inheritance.

Flashcard 33: Can a static method be overloaded?

Answer: Yes, it can. Multiple static methods can have same name, different parameters.

Flashcard 34: Can a static method call another static method?

Answer: Yes, it can. Static methods can invoke other static methods directly.

Flashcard 35: What are the parameters of the main method in Java?

Answer: String[] args. Command-line arguments passed to program.

Flashcard 36: What is the scope of a static method?

Answer: Class level. Belongs to the class, shared across all instances.

Flashcard 37: What are the parameters of the main method in Java?

Answer: String[] args. Command-line arguments passed to program.

Flashcard 38: Can static methods be overridden?

Answer: No, they can be hidden but not overridden. Static methods are resolved at compile-time, not runtime.

Flashcard 39: What is the signature of the main method in Java?

Answer: public static void main(String[] args). Required format for Java application entry point.

Flashcard 40: Can static methods access instance variables directly?

Answer: No, they cannot. Instance variables belong to objects, not the class.

Flashcard 41: What happens if you call a static method with a null reference?

Answer: No error; static method is called on class. Static methods belong to class, not instance.

Flashcard 42: Can a static method have a return type?

Answer: Yes, it can. Static methods can return values like any method.

Flashcard 43: Identify the error: static int calculate() return 0;

Answer: Missing curly braces. Method body requires braces around statements.

Flashcard 44: Identify the error: static void display() { this.show(); }

Answer: Cannot use 'this' in a static method. 'this' refers to instance, not available in static context.

Flashcard 45: Can a static method access a static variable?

Answer: Yes, it can. Static methods can access other static members.