answersLogoWhite

0

a variable holds a single type of literal. i.e. 1, bat, 345. A object is a instance of a class created by the a programmer with a set of methods which preforms certain task depending what methods have been defined.

int a = 4; // a would be the variable

Car b = new Car();// b is an object

b.carGo();// this is an method in the object car created below.

class Car(){

void carGo(){

car moves;

}

}

User Avatar

Wiki User

17y ago

Still curious? Ask our experts.

Chat with our AI personalities

EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
More answers

In Java, functions are called "methods". That means they are defined, not as independent objects, but as part of a class.

A class can contain several methods.

Classes are "templates for objects". That means that objects are defined on the basis of classes. Each object has access to all the public methods in a class.

One difference is that objects are variables, of the specified class type; while methods are really procedures or functions, belonging to a class.

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is different between function and object in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp