Basiccorejavaiq
Basiccorejavaiq
Singleton class is a class whose only one instance can be created at any given
time, in one JVM. A class can be made singleton by making its constructor private
Equals() method is defined in Object class in Java and used for checking equality
of two objects defined by business logic.
Heap memory
----------------------
1.Heap memory is used by all the parts of the application
2.Objects stored in the heap are globally accessible.
3. Memory management is based on the generation associated with each object.
4.Heap memory lives from the start till the end of application execution.
5.Whenever an object is created, it’s always stored in the Heap space.
Packages in Java, are the collection of related classes and interfaces which are
bundled together.
By using packages, developers can easily modularize the code and optimize its
reuse
1. final variable
When the final keyword is used with a variable then its value can’t be
changed once assigned.
In case the no value has been assigned to the final variable then using only
the class constructor a value can be assigned to it.
2. final method
When a method is declared final then it can’t be overridden by the inheriting
class.
3. final class
When a class is declared as final in Java, it can’t be extended by any
subclass class but it can extend other class.
Method Overriding:
- - - - - - - - - -
In Method Overriding, the subclass has the same method with the same name and
exactly the same number and type of parameters and same return type as a
superclass.
Method Overriding is to “Change” existing behavior of the method.
It is a run time polymorphism.
The methods must have the same signature.
It always requires inheritance in Method Overriding.
What is an association?
------------------------
Association is a relationship where all object have their own lifecycle and there
is no owner.
Let’s take the example of Teacher and Student.
Multiple students can associate with a single teacher and a single student can
associate with multiple teachers
but there is no ownership between the objects and both have their own lifecycle.
These relationships can be one to one, one to many, many to one and many to many.
marker interface?
-------------------
A Marker interface can be defined as the interface having no data member and member
functions.
In simpler terms, an empty interface is called the Marker interface.
The most common examples of Marker interface in Java are Serializable, Cloneable
etc.