Intermidiate Java Concepts Flashcards
What is a contructor?
It is a special method that is called when an object of a class is created, it is used to initialize an object of a class.
What are the types of constturctors?
- Default constructror
- No parameter constructor
- Parameterized constructor
What is a default constructor?
It is no parameter constructor that is automaticaly provided by the compiler, if not consturctor is defined by the programmer.
what are the possible access modifiers in java and what are thier meanings
- Private: accesible only withing the same class
- Public: Accesible from any class
- Protected: Accessible within the same package or sub classes
- default: Accessible within the same package
What is polymorphism?
Polymorphism means many forms, it allows a single function to behave differently based on different contexts or the object calling it
What are the types of polymorphism?
- Compile Time Polymorphism (mehtod overloading): thesame method name, different type or number of parameters
- Run time polymorphism (method overriding): When a subclasss provides a specific implementation of a metod alread define in its parent or supper class
What is an abstact class?
It is a class that objects cannot be created from it may contain abstact methods and concreate methods
What is an abstract method?
It is a method with no body or implementation