E01- What is Source File, Method, Class ?

In this blog we will go through all the details related to java programming with examples. So, be ready, prepare yourself and let us learn together.

First of all, We need to know few basic definitions about,

Source File

Class

Method

Source File- Source file contains the code with extension .java holds one class. Soruce file contains all the information that the program will be executing. This source file will specify all the actions will be executed by the devices like computer or mobile.

Key Note: Source file will contain one class.

Class- Class can have one or more methods. It is same like a school where we have bunch of students and each students has their own way of studying.

Key Note: Class can have more than one methods

Method: Methods code is basically a set of statements. In simple words, method is the procedure of how an action should be performed.

 

Study of Class

When you the source file in Java Virtual Machine, it looks for class you mentioned in the command line. Then it go through all the written methods within the class that can be looked like,

public static void main (string [] abcd) {

// your write all the code/methods in here

}

Note that the Java Virtual Machine will run everything that is mentioned within the curly brackets {}. Every java program or source file has to have one class & one method.

Example of Class with Method

Below in the picture you can see the structure of Source file which include one class & one method,

 

file

Public – Specifies the permission that everyone can access it within application

Class – Class is the Class

My first App – Name of the Class

{ – Opening of class

void- is the return which means out of this method there isn’t any return value

main – Name of the method

String- String must be introduced in this method with small brackets and there has to be a name for this string in this one it is args

Within the method there has to be a statement

System.out.print – Command to print in output line whatever mentioned within brackets

Every statement should end with semi colon

}-To close method & class.

That’s all for today, tomorrow will discuss further about MAIN Method.

See you….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s