Tuesday , December 6 2016
Home / JAVA / Basic concepts of Java

Basic concepts of Java

Java is Object Oriented programming language which was developed at Sun Microsystems. By object-oriented we mean, it is a technique to develop logical modules, such as classes that contain properties, methods, fields and events. An object is created in the program to represent the class. Objects are used to access data and behaviors of different software modules like classes, namespaces, etc.

 

*This statement defines the name of class which distinguishes each modular program with one another.

We can say that, Class is a template according to which objects of that class are created.

A class describes the attributes that each object will have and behavior it can exhibit through the functions defined in class.

**Constructor is a block of code which runs automatically when object of that class is created.

***Method which are inside class but outside the main function are Instance method .Instance methods cannot be directly used in main functions. We use objects for this purpose .We call the method by objects.

****In this statement as we use public access modifier in main function, so that it can be easily accessible from all classes .Public is an access modifier. We have 4 types of access modifies defined in Java to provide the access for data and behavior of class in terms of required security. The four  access modifiers are:

  1. Public:- Public members of a class are available to all the classes and to all the packages.
  2. Protected:-Protected members are accessible in the class, to the child class and also accessible to the classes of same packages. It is used in case of inheritance.
  3. Private:-This is the most restrictive access level. Private members are accessible only within the class.
  4. Default: – Default access modifier is set if u do not set any access modifier explicitly. And it is accessible to different members of same class and different classes of same package. If we do not provide any access modifier than it automatically consider it default access modifier.

->The main function is static which means that main function is common for all the class and for all the objects it executes in the similar manner.

->The main function is void which means it does not return anything.

-> The arguments in the main function are String by default.

*****Data are the variables in the program and behavior are the methods or function implementation which behaves accordingly.

Also See:   Static keyword in java

Check Also

Program for Matrix Multiplication in JAVA

Matrix Multiplication:– Here is given a Java Program for Matrix Multiplication also call matrix product. In ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.