Tuesday , January 23 2018
Home / JAVA / Basic concepts of Java: Quick Revision

Basic concepts of Java: Quick Revision

Here is the Quick Revision for those who have to clear their concepts of Java in few Minutes. Java is Object Oriented programming language which was developed at Sun Micro systems. 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 behaviours of different software modules like classes, namespaces, etc.

class NewClass     *
NewClass() // this act as a constructor **
System.out.println("Constructor"); // simple printing function which is predefined 
void Function()  // method ***
{           //  the implementation of method is defined inside the function.
System.out.println("Hello World");
public static void main(String args[])  // main function  ****
NewClass obj=new NewClass();            // object is created to access data and behaviour *****
obj.Function();  // calling function through object
System.out.println("Know the Basics of Java"); // simple print statement to print something
}  // end of main
} // end of class

Explained Point to point Concepts for Quick revision

In the above program the star are marked after the lines in few line comments and here are the illustrations for them:

Also See:   java program for pattern#6

*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 behaviour 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.

Also See:   Convert Writer to String in Java

****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 behaviour 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 you 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.
Also See:   Java program for producing prime numbers for given range

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

Check Also

Java program to implement polymorphism

Java program to implement polymorphism: Polymorphism is a technique in java with which you can ...

Leave a Reply

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