In this article we learn the what is object in java, calling methods in java and what new keyword does.
What is Object in Java?
1. An object in java is an instance of a class which is pointing to its own memory.
2. An object is an identifiable entity with some characteristics, state, and behavior.
3. Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
4. Object is created through new keyword
5. Syntax: className obj=New className ();
Calling methods in java
1. Static to Non-Static
A) Call by Object.
2. Static to Static
A) Direct by Name: Inside Same Class.
B) By Class Name: Standard
C) By Object Name: Non-Standard
3. Non-Static to Static
A) Direct by Name: Inside Same Class.
B) By Class Name: Standard
C) By Object Name: Non-Standard
4. Non-Static to Non-Static
A) Direct by Name
B) By using this Keyword.
C) By Object Name ->Non-Standard
What new keyword does?
When we use the new operator, several things happen: first, the new instance of the given class is created, and memory is allocated for it. In addition (and most importantly), when the new object is created, a special method defined in the given class is called. This special method is called a constructor.