Warning: mysqli_connect(): (HY000/2002): Connection refused in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 38

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 40

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 41

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 45

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 48

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 49
Basic concepts of Java: Quick Revision - Get Program Code
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:

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

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

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

Check Also

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which ...

Leave a Reply

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

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