answersLogoWhite

0


Best Answer

The largest structure in a java program is a Class. The structure that is the second largest, and a sub-component of a Class is a Method. Each Method has a name and code inside of it that performs a function. Whenever the Method is called upon by naming it the code inside of it is executed. To use a Method in a separate Class requires an Object to be created inside of the separate Class and then the Object is stated along with the Method to be able to perform a Method's specific function.

If the method is defined as static then a class object is not required to call this method.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

The same as user-defined methods. Use the method name, usually with an object or class name in front of it, and a list of parameters if applicable; and if you need the return value, assign it to a variable:

returnValue = myObject.standardMethod(parameter1, parameter2);

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

You use methods to implement behavior. Methods usually alter the state of an object, although there are also methods that simply allow you to get and set specific members.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

As compared to what? If you use Java, all commands have to be written in methods, so there is really no alternative.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

some sample methods are:

public String getName(){

return this.name;

}

public int multiply(int a, int b){

return a * b;

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you use predefined methods in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Examples of codes in java?

public class Hello{//opens the classpublic static void main(String args[]){//opens the main methodSystem.out.println("Hello World");}//closes the main method}//closes the classNote: The compiler all the sentences that have "//" before them.


What is the use of api in java?

The API is a reference for all predefined classes provided by the java language. This will allow the programmer to utilize the classes into their programs. The API provides packages, classes, methods, constants, etc.


Why keywords in java important?

In the Java programming language, a keyword is one of 53 reserved words that have a predefined meaning in the language; because of this, programmers cannot use keywords as names for variables, methods, classes, or as any other identifier.


What is function overloading in java?

Any function or method in Java that is coded by the programmer is called a user defined method in Java. The JAVA API (Application Programming Interface) has a set of predefined classes & methods that are for our usage. Whatever methods we create apart from these are termed as user defined methods. In java we not use the term functions. We call them "Methods"


Is main a predefined function in java?

No. It is a user defined function which the person who is creating the java class has to code by himself.


What is the use of functions in java?

Same as in other languages. To organize commands into logical pieces. However, in Java the functions are called "methods". This is related to the fact that in Java, methods or functions are defined as part of a class.


How can i see all the classes and interfaces present in a predefined package in java in command prompt?

use the jar command like this: jar tvf mypackage.jar


Is it possible to override overloaded methods why?

Yes. Overloaded methods are also Java methods and all Java methods can be overridden.


What is the use of thread in java?

Thread is a single sequential flow of control within program. Each flow of control may be thought of as a seperate lines of code(module) is called as thread.Actually thread is a predefined class in java. threads are used to handle Exceptions in java.


What are the different types of package in java?

1.user defined packages 2.predefined packages


Explain three different methods in java?

There are three different methods /functions in java are there : 1)computational methods.2)manipulative methods.3)procedural methods.


Are binary search and linear search already defined method in some class in java and what class is this?

You can check out the Arrays.binarySearch group of methods for searching sorted arrays. There is no predefined linear search for arrays, probably because it is trivially easy to implement. If you have some other data structure to search, the Collections.binarySearch methods should work for you. Most collections can also be converted to a List representation, which has a predefined indexOf method for linear searching.