Java follows the priciples of object oriented programming,are quiet popular as they help in reducing the complexity of programs.
Eg:as library management and inventory management,needs object oriented language,such as Java.
Basic Defnitions:
Class: Characteristics and behaviour of an object.Example:If u r creating a game application,each game which user plays from application are equivalent to a class.
Attributes like score,players can be specified as member variables and their behaviour is mentioned as methods.
class {
//Declaration of member variables
//Declaration of methods
}
Keypoints:
Name of class is equivalent to name of file.(if main class is declared public).
First letter must be capitalised.
Class name should not be a keyword.
Variables:
Container for storage of data.
Methods:
Statements which are intended to form a specific task.
A method called compute score can be used as a method in above example.
(parameter list) //method declaration { }
Objects:
Instance of a class and has unique identity.
class name object name;//declaration of object of a class.
object name=new class name();//create an object;new keyword allocates memory to object.