As no public class any name should be use for class.
Atmost one class must be declare public- in such case this class will be name for java class
Public class name and the name of the programme are related to each other.
Import Statement:
all the classes and interfaces present in the package is available but not the subpackage classes.
Package:
Any java-source file atmost one package-statement is allowed.
Order is important: always package statement comes first.
Abstract method:
It has only declaration but not implementation.
Abstract method do not have body
Such method should be declared with abstract keywod.
Abstract Class:
These classes are partially implemented.
Not possible to create object(instantiation is not possible).
If a class contains one abstract method than the class compulsory declared as Abstract.
Child class is responsible to provide the implementation for all parent class abstract methods.
If not sure about the implementation of the method than declare the child class as abstract too.
Modifiers:
Public:
Can be accessed from any where ie within the same package or outside the package.
If a method is access outside the package than the methods belong should belong to Public class
only. Not possible to access public metocd from one package to the other package if class in nopt
declared as public.
Private:
Member is accessible within same class
Default
Member is accessible within same Package
Protected:
If want to access parent class method only child reference is used, no parent reference is allowed.
INTERFACE:
Whenever implementing the interface method it should be declare as public.
While implementing the interface each and every abstract method of the interface we should
provide implementation if not than declare the class as abstract.
OOPS concepts:
Data hiding:
Hiding data from outside access.
We can declare variable as private to implement data-hiding.
Advantage: Security
Abstraction:
Hiding internal implementation for purpose of security,maintainability,modularity,etc
Encapsulation:
The process of binding/grouping data under corresponding methods or behaviour is called
encapsulation.
https://www.youtube.com/watch?
v=Rko5CzkVjMM&list=PLd3UqWTnYXOkwluXExifmJWKkvGa1ywWp&index=10
Constructor
For every object separate copy of instance variable is created and for those instance variable default
value will be provided by JVM
Purpose:
Constructor concept is designed to perform initialization of an object.
Constructors provides values for instance variables
Return type concept not applicable for constructor, not even void.
It is legal to have method name as class name but it is not recommended.