What is a “Memory leak” in Java?
In Java, when a developer wants to create and use a new object using, e.g. new Integer(5), he doesn’t have to allocate memory – this is being taken care of by the Java Virtual Machine (JVM). During the life of the application JVM periodically checks which objects in memory are still being used and which are not. Unused objects can be discarded and memory reclaimed and reused again. This process is called garbage collection and the corresponding piece of JVM is called a Garbage Collector or GC.
How can GC distinguish between the unused objects and the ones the application will use at some point in time in the future? The basic algorithm can be described as follows:
- There are some objects which are considered “important” by GC. These are called GC roots and are (almost) never discarded. They are, for example, currently executing method’s local variables and input parameters, application threads, references from native code and similar “global” objects.
- Any object referenced from those GC roots are assumed to be in use and not discarded. One object can reference another in different ways in Java, most commonly being when object A is stored in a field of object B. In that case, we say “B references A”
- The above process is repeated until all objected that can be transitively reached from GC roots are visited and marked as “in use”
- Everything else is unused and can be thrown away.
LDAP and Active directory
Active Directory( Microsoft's implementation) is a database based system that provides authentication, directory, policy, and other services in a Windows environment
LDAP (Lightweight Directory Access Protocol) is an application protocol for querying and modifying items in directory service providers like Active Directory, which supports a form of LDAP.
OOPS Concept.
OOPS Concepts are mainly 4
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphisam
Abstraction:-Hidding non-essential features and showing the
essential features
(or)
Hidding unnecessary data from the users details,is called
abstraction.
Real Time example:TV Remote Button
Encapsulation: Writing Operations and methods stored in a single
class.This is Called Encapsulation
Real Time Example:Medical Capsuals
Inheritance: The New Class is Existing from Old Class,i.e SubClass is
Existing from Super Class.
Real Time Example: Father and Son Relationship
Polymorphisam: Single Form behaving differently in different Situations.
**
OOPS Concept.
OOPS Concepts are mainly 4
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphisam
Abstraction:-Hidding non-essential features and showing the
essential features
(or)
Hidding unnecessary data from the users details,is called
abstraction.
Real Time example:TV Remote Button
Encapsulation: Writing Operations and methods stored in a single
class.This is Called Encapsulation
Real Time Example:Medical Capsuals
Inheritance: The New Class is Existing from Old Class,i.e SubClass is
Existing from Super Class.
Real Time Example: Father and Son Relationship
Polymorphisam: Single Form behaving differently in different Situations.
**
A Washing Machine and It's Power Button
What is the function that power button does? Switches the machine on (obviously). But did u ever imagined the inside mechanism. Doesn't matter unless it's functioning well. That's encapsulation. The object is wrapped and inner details are hidden. Only thing is that object can be called and used. User friendly!
Second, A Postman
He is not bothered what is inside your parcel. He's job is to read the address and deliver. It's abstraction. It is safe isn't it? Just get a job done by providing few details.
Association, Aggregation, Composition:
- Association is a relationship where all objects have their own lifecycle and there is no owner.
Association - I have a relationship with an object.
Foo uses Barpublic class Foo {
void Baz(Bar bar) {
}
};
- Aggregation is a specialised form of Association where all objects have their own lifecycle, but there is ownership and child objects can not belong to another parent object.Let's take an example of Department and teacher. A single teacher can not belong to multiple departments, but if we delete the department, the teacher object will not be destroyed. We can think about it as a “has-a” relationship.
For two objects,
Foo and Bar the relationships can be defined
Association - I have a relationship with an object.
Foo uses Bar
Composition - I own an object and I am responsible for its lifetime, when
Foo dies, so does Bar
Aggregation - I have an object which I've borrowed from someone else. When
Foo dies, Bar may live on.
|
- Composition is again specialised form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object does not have its lifecycle and if parent object is deleted, all child objects will also be deleted.Let's take again an example of relationship between House and Rooms. House can contain multiple rooms - there is no independent life of room and any room can not belong to two different houses. If we delete the house - room will automatically be deleted.Let's take another example relationship between Questions and Options. Single questions can have multiple options and option can not belong to multiple questions. If we delete the questions, options will automatically be deleted.
Composition - I own an object and I am responsible for its lifetime, when
Foo dies, so does Barpublic class Foo {
private Bar bar = new Bar();
}
[Main business classes in java application]
Abstraction and Encapsulation
http://www.java67.com/2012/08/difference-between-abstraction-and-encapsulation-java-oops.html