Anatomy of a Class - AP Computer Science A
Card 1 of 30
What keyword is used to inherit from a class?
What keyword is used to inherit from a class?
Tap to reveal answer
extends. Creates parent-child relationship between classes.
extends. Creates parent-child relationship between classes.
← Didn't Know|Knew It →
What is an abstract class?
What is an abstract class?
Tap to reveal answer
A class that cannot be instantiated and may contain abstract methods. Serves as template requiring subclass implementation.
A class that cannot be instantiated and may contain abstract methods. Serves as template requiring subclass implementation.
← Didn't Know|Knew It →
Can a Java class implement multiple interfaces?
Can a Java class implement multiple interfaces?
Tap to reveal answer
Yes, a class can implement multiple interfaces. Multiple inheritance through interfaces is allowed.
Yes, a class can implement multiple interfaces. Multiple inheritance through interfaces is allowed.
← Didn't Know|Knew It →
What is the default value of a boolean field in Java?
What is the default value of a boolean field in Java?
Tap to reveal answer
false. Primitive types initialize to false automatically.
false. Primitive types initialize to false automatically.
← Didn't Know|Knew It →
Identify the default value of an int field in Java.
Identify the default value of an int field in Java.
Tap to reveal answer
- Numeric primitives initialize to zero by default.
- Numeric primitives initialize to zero by default.
← Didn't Know|Knew It →
Which access modifier allows visibility to all classes?
Which access modifier allows visibility to all classes?
Tap to reveal answer
public. Provides unrestricted access from anywhere.
public. Provides unrestricted access from anywhere.
← Didn't Know|Knew It →
Which access modifier restricts visibility to the containing class?
Which access modifier restricts visibility to the containing class?
Tap to reveal answer
private. Most restrictive access level for data hiding.
private. Most restrictive access level for data hiding.
← Didn't Know|Knew It →
What is encapsulation in Java?
What is encapsulation in Java?
Tap to reveal answer
Hiding data fields using access modifiers. Core OOP principle for data protection.
Hiding data fields using access modifiers. Core OOP principle for data protection.
← Didn't Know|Knew It →
What is the purpose of a constructor?
What is the purpose of a constructor?
Tap to reveal answer
To initialize a new object of a class. Sets initial values for object fields.
To initialize a new object of a class. Sets initial values for object fields.
← Didn't Know|Knew It →
What keyword is used to inherit from a class?
What keyword is used to inherit from a class?
Tap to reveal answer
extends. Creates parent-child relationship between classes.
extends. Creates parent-child relationship between classes.
← Didn't Know|Knew It →
Which method is used to compare two objects for equality?
Which method is used to compare two objects for equality?
Tap to reveal answer
equals(). Compares object content rather than references.
equals(). Compares object content rather than references.
← Didn't Know|Knew It →
Identify the superclass of all classes in Java.
Identify the superclass of all classes in Java.
Tap to reveal answer
Object. Root class that all Java classes inherit from.
Object. Root class that all Java classes inherit from.
← Didn't Know|Knew It →
What is an abstract class?
What is an abstract class?
Tap to reveal answer
A class that cannot be instantiated and may contain abstract methods. Serves as template requiring subclass implementation.
A class that cannot be instantiated and may contain abstract methods. Serves as template requiring subclass implementation.
← Didn't Know|Knew It →
Which keyword is used to declare an abstract class?
Which keyword is used to declare an abstract class?
Tap to reveal answer
abstract. Prevents direct instantiation of the class.
abstract. Prevents direct instantiation of the class.
← Didn't Know|Knew It →
What is polymorphism in Java?
What is polymorphism in Java?
Tap to reveal answer
The ability to process objects differently based on their data type. Enables one interface with multiple implementations.
The ability to process objects differently based on their data type. Enables one interface with multiple implementations.
← Didn't Know|Knew It →
Identify the method that returns a string representation of an object.
Identify the method that returns a string representation of an object.
Tap to reveal answer
toString(). Provides readable format for object display.
toString(). Provides readable format for object display.
← Didn't Know|Knew It →
Which access modifier allows visibility within the same package only?
Which access modifier allows visibility within the same package only?
Tap to reveal answer
default (no modifier). Package-private access when no modifier specified.
default (no modifier). Package-private access when no modifier specified.
← Didn't Know|Knew It →
What is a method in a Java class?
What is a method in a Java class?
Tap to reveal answer
A block of code that performs a specific task. Defines behavior that objects can perform.
A block of code that performs a specific task. Defines behavior that objects can perform.
← Didn't Know|Knew It →
Identify the method that initializes an object.
Identify the method that initializes an object.
Tap to reveal answer
Constructor. Special method that sets up new object instances.
Constructor. Special method that sets up new object instances.
← Didn't Know|Knew It →
What is a field in a Java class?
What is a field in a Java class?
Tap to reveal answer
A variable declared within a class. Stores data as part of an object's state.
A variable declared within a class. Stores data as part of an object's state.
← Didn't Know|Knew It →
Identify the method that is automatically called when an object is created.
Identify the method that is automatically called when an object is created.
Tap to reveal answer
Constructor. Invoked immediately upon object instantiation.
Constructor. Invoked immediately upon object instantiation.
← Didn't Know|Knew It →
What is inheritance in Java?
What is inheritance in Java?
Tap to reveal answer
A mechanism where one class acquires the properties of another. Child class gains parent's properties and methods.
A mechanism where one class acquires the properties of another. Child class gains parent's properties and methods.
← Didn't Know|Knew It →
Which access modifier restricts visibility to the containing class?
Which access modifier restricts visibility to the containing class?
Tap to reveal answer
private. Most restrictive access level for data hiding.
private. Most restrictive access level for data hiding.
← Didn't Know|Knew It →
What is the signature of a method?
What is the signature of a method?
Tap to reveal answer
The method's name and parameter list. Identifies method for compilation and overriding.
The method's name and parameter list. Identifies method for compilation and overriding.
← Didn't Know|Knew It →
What is the purpose of the 'this' keyword?
What is the purpose of the 'this' keyword?
Tap to reveal answer
Refers to the current instance of a class. Distinguishes between instance and parameter variables.
Refers to the current instance of a class. Distinguishes between instance and parameter variables.
← Didn't Know|Knew It →
What is a package in Java?
What is a package in Java?
Tap to reveal answer
A namespace that organizes classes and interfaces. Groups related classes for organization.
A namespace that organizes classes and interfaces. Groups related classes for organization.
← Didn't Know|Knew It →
Identify the method that returns a string representation of an object.
Identify the method that returns a string representation of an object.
Tap to reveal answer
toString(). Provides readable format for object display.
toString(). Provides readable format for object display.
← Didn't Know|Knew It →
What is the difference between == and equals()?
What is the difference between == and equals()?
Tap to reveal answer
== checks reference; equals() checks value equality. Reference vs content comparison distinction.
== checks reference; equals() checks value equality. Reference vs content comparison distinction.
← Didn't Know|Knew It →
What is a field in a Java class?
What is a field in a Java class?
Tap to reveal answer
A variable declared within a class. Stores data as part of an object's state.
A variable declared within a class. Stores data as part of an object's state.
← Didn't Know|Knew It →
Can a Java class implement multiple interfaces?
Can a Java class implement multiple interfaces?
Tap to reveal answer
Yes, a class can implement multiple interfaces. Multiple inheritance through interfaces is allowed.
Yes, a class can implement multiple interfaces. Multiple inheritance through interfaces is allowed.
← Didn't Know|Knew It →