Java main method call

writing4angels By writing4angels, 26th Nov 2010 | Follow this author | RSS Feed | Short URL http://nut.bz/1rbva_28/
Posted in Wikinut>Guides>Technology>Computer Software

Java is an object oriented programming language and methods are called generally through the class objects.

Java main method call

When a class is declared it just acts as a blueprint about how an object will look like and once you create an object memory is assigned to the object and according to the variables defined inthe class memory size is allocated.

Let us have a quick look at an example where a display method declared in the same class will be called from the java main method.

class MethodCall

{

public static void main(String args)

{

MethodCall obj=new MethodCall();

obj.display();

}


public void display()

{

System.out.println(”display method called”);

}

}

As shown in the above example display method prints a statement on the command line and is called from the main method after creating an object. Java method call can also be different when we talk about static methods. Java method call also requires arguments when parameters are specified in the methods.

Tags

Interview Questions Java, Java, Java Main Method, Java Programming, Java Script, Java-Deprived, Javascript, Main Method Call, Main Method In Java, Main Method Tips

Meet the author

author avatar writing4angels
A real lover of literature and I appreciate good works of other fellow writers who have given priceless contribution to the content on Internet.

Share this page

moderator johnnydod moderated this page.
If you have any complaints about this content, please let us know

Comments

Add a comment
Username
Can't login?
Password