Java classes, constructors, inheritance, interfaces, abstract classes, records, enums, access modifiers, static and final, and inner classes.
41 cards · basic cards · AI-written, checked twice. Edit anything.
- What is a class?
Show answer
A blueprint for creating objects that defines fields (state) and methods (behavior).
- What is an object?
Show answer
An instance of a class, created using the new keyword.
- What keyword is used to create an object from a class?
Show answer
The new keyword, followed by the class name and a constructor call.
- What is a constructor?
Show answer
A special method that initializes an object when it is created.
- What is the default constructor?
Show answer
A no-argument constructor automatically provided by Java if no constructors are explicitly defined.
- What is constructor overloading?
Show answer
Defining multiple constructors in the same class with different parameter lists.
- What keyword calls another constructor in the same class?
Show answer
The this keyword, written as this(arguments).
- What keyword is used to access the parent class from a subclass?
Show answer
The super keyword.
- What keyword establishes inheritance in Java?
Show answer
The extends keyword, allowing a child class to inherit from a parent class.
- What is method overriding?
Show answer
Redefining a parent class method in a child class with the same method signature.
- Does Java support multiple inheritance for classes?
Show answer
No, a class can extend only one other class.
- What is the relationship between a class and an interface in Java?
Show answer
A class implements an interface; it does not inherit from it.
- What is an interface?
Show answer
A contract that defines a set of abstract methods that any implementing class must provide.
- What keyword implements an interface?
Show answer
The implements keyword.
- What types of fields can an interface contain?
Show answer
Only constants, which are implicitly public static final.