- A class can has only public or default (no modifier) access specifier.
- It can be either abstract, final or concrete (normal class).
- It must has the Class keyword, and class must is followed by a legal identifier.
- It may optionally extend one parent class. By default, it'll extend Java.lang.Object.
- It may optionally implement any number of comma-separated interfaces.
- The class ' s variables and methods are declared within a set of curly braces
{} .
- Each . Java source file could contain only a public class. A source file may contain any number of the default visible classes.
- Finally, the source file name must match the public class name and it must has a. java suffix.
How a class was initialized in Java
Class is initialized in Java when a instance of class is created using either new operator or using reflection using
Class.forName (). A class is also said to being initialized when a static method of class was invoked or a static filed is assigned
How to make a copy of the entire Java object with it state
Make this class implement cloneable interface and call Clone () method on the its Object.clone () method was defined in Object class which is the parent of any Java class by default.
Java Method:
In Java if you pass a primitive type to a method It's pass by value
When you pass the object of any of the type to a method it is passed as reference
Java Class/method