AP Computer Science a Flashcards: Abstraction And Program Design

Study Abstraction And Program Design 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

Abstraction And Program Design

0 mastered0 still learning

0% Complete

QUESTION
1/ 62

Identify the keyword to declare a class as abstract.

Tap card or press Space to flip

ANSWER

The 'abstract' keyword is used to declare an abstract class. Marks class as incomplete, requiring subclass implementation.

How well did you know it?

Card 1 / 62

What this deck covers

This deck focuses on Abstraction And Program Design, 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: Identify the keyword to declare a class as abstract.

Answer: The 'abstract' keyword is used to declare an abstract class. Marks class as incomplete, requiring subclass implementation.

Flashcard 2: Which keyword is used to implement an interface in Java?

Answer: The 'implements' keyword is used to implement an interface. Creates contractual obligation to provide method implementations.

Flashcard 3: What is a concrete class?

Answer: A concrete class is a class that has no abstract methods. Can be instantiated directly, no abstract methods present.

Flashcard 4: What is the significance of the 'public' keyword?

Answer: 'public' makes a class, method, or field accessible from any other class. Broadest access level, no restrictions on usage.

Flashcard 5: What is the result of 'System.out.println(7.0/2);'?

Answer: The result is 3.5, due to floating-point division. Double operand promotes calculation to floating-point arithmetic.

Flashcard 6: Identify the keyword to declare a class as abstract.

Answer: The 'abstract' keyword is used to declare an abstract class. Marks class as incomplete, requiring subclass implementation.

Flashcard 7: Identify a benefit of using abstraction.

Answer: Abstraction reduces complexity and increases efficiency. Simplifies development by hiding unnecessary implementation details.

Flashcard 8: Identify the error: 'public void myMethod();'

Answer: Methods must have a body unless declared abstract. Non-abstract methods require implementation in concrete classes.

Flashcard 9: What is the significance of the 'private' keyword?

Answer: 'private' restricts access to the class itself. Most restrictive access, only within declaring class.

Flashcard 10: Identify a benefit of using abstraction.

Answer: Abstraction reduces complexity and increases efficiency. Simplifies development by hiding unnecessary implementation details.

Flashcard 11: What is an abstract class?

Answer: An abstract class cannot be instantiated and may contain abstract methods. Serves as template, requires subclasses for instantiation.

Flashcard 12: What is the significance of the 'protected' keyword?

Answer: 'protected' allows access within the same package and subclasses. Package access plus inheritance-based access for subclasses.

Flashcard 13: What is a static method in Java?

Answer: A static method belongs to the class rather than any object instance. Called on class itself, not requiring object instantiation.

Flashcard 14: What is the significance of the 'protected' keyword?

Answer: 'protected' allows access within the same package and subclasses. Package access plus inheritance-based access for subclasses.

Flashcard 15: Identify the error: 'class B extends A, C {}'

Answer: Java does not support multiple inheritance of classes. Classes can only extend one superclass in Java.

Flashcard 16: What is abstraction in computer science?

Answer: Abstraction is hiding complex details to simplify problem solving. Core concept of managing complexity by focusing on essential features.

Flashcard 17: What is the result of 'System.out.println(7/2);'?

Answer: The result is 3, due to integer division. Both operands are integers, so result truncates decimal portion.

Flashcard 18: Which keyword is used to inherit a class in Java?

Answer: The 'extends' keyword is used to inherit a class. Establishes is-a relationship between parent and child classes.

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

Answer: public static void main(String[] args). Entry point for Java applications, must match exact format.

Flashcard 20: Identify the error: 'class A { static int x; }'

Answer: No error; the syntax is correct. Static variables are properly declared at class level.

Flashcard 21: What is a superclass in Java?

Answer: A superclass is the class from which a subclass inherits. Also called parent class, provides structure for child classes.

Flashcard 22: Identify the error: 'class B extends A, C {}'

Answer: Java does not support multiple inheritance of classes. Classes can only extend one superclass in Java.

Flashcard 23: What is polymorphism in OOP?

Answer: Polymorphism allows for methods to do different things based on the object it is acting upon. Enables same method name to behave differently across classes.

Flashcard 24: Identify the error: 'public void myMethod(int a, int a)'.

Answer: Duplicate parameter name 'a'. Parameter names must be unique within method signature.

Flashcard 25: What is a subclass in Java?

Answer: A subclass is a class that inherits from another class, the superclass. Also called child class, extends functionality of parent class.

Flashcard 26: What is abstraction in computer science?

Answer: Abstraction is hiding complex details to simplify problem solving. Core concept of managing complexity by focusing on essential features.

Flashcard 27: What is the default access modifier in Java?

Answer: The default access modifier is package-private. Accessible within package but not from outside packages.

Flashcard 28: What is a constructor in Java?

Answer: A constructor is a special method to initialize objects. Called automatically when creating new object instances.

Flashcard 29: Identify an example of polymorphism in Java.

Answer: Method overriding is an example of polymorphism. Subclass methods can replace superclass method behavior.

Flashcard 30: Identify the error: 'interface I { void method(){} }'

Answer: Interfaces cannot have method bodies. Only default and static methods can have implementations.

Flashcard 31: What is polymorphism in OOP?

Answer: Polymorphism allows for methods to do different things based on the object it is acting upon. Enables same method name to behave differently across classes.

Flashcard 32: What is a concrete class?

Answer: A concrete class is a class that has no abstract methods. Can be instantiated directly, no abstract methods present.

Flashcard 33: Which keyword is used to inherit a class in Java?

Answer: The 'extends' keyword is used to inherit a class. Establishes is-a relationship between parent and child classes.

Flashcard 34: Correct this snippet: 'public class Test { private Test() {} }'

Answer: No error; this is a valid constructor. Private constructors are legal, often used in singleton patterns.

Flashcard 35: How does encapsulation improve code robustness?

Answer: Encapsulation protects an object's internal state from unintended modification. Private fields prevent direct external manipulation of data.

Flashcard 36: Correct this snippet: 'int x = new int();'.

Answer: Use 'int x;' or 'Integer x = new Integer();'. Primitives cannot use constructor syntax, only reference types.

Flashcard 37: Identify a method to achieve abstraction in Java.

Answer: Abstraction can be achieved using abstract classes and interfaces. Both provide contracts without revealing implementation details.

Flashcard 38: Identify the error: 'interface I { void method(){} }'

Answer: Interfaces cannot have method bodies. Only default and static methods can have implementations.

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

Answer: public static void main(String[] args). Entry point for Java applications, must match exact format.

Flashcard 40: What is the purpose of the 'final' keyword in Java?

Answer: 'final' is used to declare constants, prevent inheritance, and prevent method overriding. Prevents modification, inheritance, or method overriding.

Flashcard 41: What is the significance of the 'public' keyword?

Answer: 'public' makes a class, method, or field accessible from any other class. Broadest access level, no restrictions on usage.

Flashcard 42: What is the purpose of the 'this' keyword in Java?

Answer: 'this' is used to refer to the current object instance. Distinguishes between instance variables and parameters with same names.

Flashcard 43: What is the purpose of the 'this' keyword in Java?

Answer: 'this' is used to refer to the current object instance. Distinguishes between instance variables and parameters with same names.

Flashcard 44: What is the main advantage of using inheritance?

Answer: Inheritance promotes code reuse. Avoids duplicating code across multiple related classes.

Flashcard 45: Identify the error: 'class A { static int x; }'

Answer: No error; the syntax is correct. Static variables are properly declared at class level.

Flashcard 46: Correct this snippet: 'int x = new int();'.

Answer: Use 'int x;' or 'Integer x = new Integer();'. Primitives cannot use constructor syntax, only reference types.

Flashcard 47: What is a subclass in Java?

Answer: A subclass is a class that inherits from another class, the superclass. Also called child class, extends functionality of parent class.

Flashcard 48: What does 'inheritance' mean in OOP?

Answer: Inheritance allows a class to inherit fields and methods from another class. Enables code reuse by establishing parent-child class relationships.

Flashcard 49: What is the result of 'System.out.println(7.0/2);'?

Answer: The result is 3.5, due to floating-point division. Double operand promotes calculation to floating-point arithmetic.

Flashcard 50: What is method overriding?

Answer: Method overriding is redefining a superclass method in a subclass with the same signature. Allows subclasses to provide specific implementations.

Flashcard 51: Identify an example of polymorphism in Java.

Answer: Method overriding is an example of polymorphism. Subclass methods can replace superclass method behavior.

Flashcard 52: Define encapsulation in object-oriented programming.

Answer: Encapsulation is bundling data with methods that operate on it. Key principle protecting data integrity through controlled access.

Flashcard 53: Identify a method to achieve abstraction in Java.

Answer: Abstraction can be achieved using abstract classes and interfaces. Both provide contracts without revealing implementation details.

Flashcard 54: What is method overloading?

Answer: Method overloading is having multiple methods with the same name but different parameters. Provides flexible method calls with different parameter sets.

Flashcard 55: What is a package in Java?

Answer: A package is a namespace for organizing classes and interfaces. Groups related classes to prevent naming conflicts.

Flashcard 56: Define encapsulation in object-oriented programming.

Answer: Encapsulation is bundling data with methods that operate on it. Key principle protecting data integrity through controlled access.

Flashcard 57: What is a superclass in Java?

Answer: A superclass is the class from which a subclass inherits. Also called parent class, provides structure for child classes.

Flashcard 58: How does encapsulation improve code robustness?

Answer: Encapsulation protects an object's internal state from unintended modification. Private fields prevent direct external manipulation of data.

Flashcard 59: What is a constructor in Java?

Answer: A constructor is a special method to initialize objects. Called automatically when creating new object instances.

Flashcard 60: Identify the error: 'public void myMethod(int a, int a)'.

Answer: Duplicate parameter name 'a'. Parameter names must be unique within method signature.

Flashcard 61: What is the significance of the 'private' keyword?

Answer: 'private' restricts access to the class itself. Most restrictive access, only within declaring class.

Flashcard 62: What does 'inheritance' mean in OOP?

Answer: Inheritance allows a class to inherit fields and methods from another class. Enables code reuse by establishing parent-child class relationships.