Chapter 7 - Abstraction Flashcards
Abstraction definition
Abstraction in Java is a fundamental Object-Oriented Programming (OOP) concept that involves simplifying complex systems by modeling real-world entities as classes with well-defined attributes and behaviors. It focuses on hiding the implementation details while exposing only the essential characteristics of an object. Abstraction allows developers to create a clear and generalized representation of objects, promoting modularity, reusability, and a higher level of understanding in software design. It is achieved through abstract classes, interfaces, and the definition of abstract methods that serve as contracts for concrete subclasses.
What java uses to implement Abstraction?
Abstract classes and methods
Interfaces
Method Overloading
Enums
Generics
Static methods
What is abstract classes
Abstract classes in Java serve as a blueprint for other classes. They allow you to define common methods and fields that will be shared among the concrete (non-abstract) subclasses while also providing a level of abstraction.
What can you say about instantiationg of abstract class?
Abstract classes cannot be instantiated on their own. You cannot create objects directly from an abstract class. Instead, they are meant to be extended by concrete subclasses that provide implementations for the abstract methods defined in the abstract class.
What kind of methods does abstract class provide?
Abstract classes can have both concrete (with an implementation) and abstract methods (without an implementation). Abstract methods serve as placeholders that must be implemented by any concrete subclass that extends the abstract class.
Can abstract class have a constructor?
Abstract classes can have constructors. When a concrete subclass is instantiated, the constructor of the abstract class is called before the constructor of the subclass.
how interfaces support abstraction in Java?
Abstract Method Signatures
Interfaces declare methods without providing implementations. These methods are called “abstract methods” and serve as a contract that concrete classes must adhere to.
I dont understand how method overloading supports abstraction
Method overloading is a feature in Java that allows a class to have multiple methods with the same name in the same class but with different parameter lists.