answersLogoWhite

0

A field is an attribute. A field may be a class's variable, an object's variable, an object's method's variable, or a parameter of a function.

class bike{ static int bikes;int gear;int cadence;

void create( int newGear, int newCadence ){bikes = bikes + 1;gear = newGear;

cadence = newCadence;}

int getSpeed(){int speed = gear*cadence*5*3.141;return speed;}}

'bikes' is a class's variable (class variable) (static field).

'gear' and 'cadence' could be an object's variables (instance variables) (non-static fields).

'speed' is an object's method's variable (local variable).

'newGear' and 'newCadence' are parameters of a function (parameters).

Refer to related links section

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao

Add your answer:

Earn +20 pts
Q: What is a field in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp