Describe member variables vs. local variables, JAVA Programming

Assignment Help:

Describe Member Variables vs. Local Variables ?

class Car {

String licensePlate = ""; // member variable
double speed; = 0.0; // member variable
double maxSpeed; = 123.45; // member variable

boolean isSpeeding() {
double excess; // local variable
excess = this.maxSpeed - this.speed;
if (excess < 0) return true;
else return false;
}

}
Until now all the programs you've look quite simple in structure. Every had exactly one class. This class had a single method, main(), that golds all the program logic and variables. The variables within those classes were all local to the main() method. They could not be accessed by anything outside the main() method. These are called as local variables.

This sort of program is the amoeba of Java. Everything the program needs to live is contained inside a single cell. It's quite an well-organized arrangement for little organisms, other than it breaks down while you need to design something bigger or more complex.

The licensePlate, speed and maxSpeed variables of the Car class, thus, belong to a Car object, not to any individual method. They are elaborates outside of any methods but inside the class and are used in different techniques. They are known as member variables or fields.

Member variable, instance variable, and field are different words in that mean the similar thing. Field is the preferred term in Java. Member variable is the preferred term in C++.

A member is not the similar as a member variable or field. Members included both fields and methods.


Related Discussions:- Describe member variables vs. local variables

Data structure, consider the file name cars.text each line in the file cont...

consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is represen

Need cocos2d-x developer - puzzle game, cocos2d-x puzzle game for kids P...

cocos2d-x puzzle game for kids Project Description: I am seeking a skilled, reliable, and not very expensive cocos2d-x developer (with experience with iOS, Android, and prefe

Explain the different kinds of exceptions, Explain The different kinds of e...

Explain The different kinds of exceptions ? Checked Exceptions  : Environmental error in which cannot necessarily be detected through testing; e.g. broken socket, disk full,

Java , what is thread synchronization

what is thread synchronization

Write the java rmi interface definition, In the programming assignments, yo...

In the programming assignments, you are going to develop a simple distributed ticket reservation system (DTRS). This system is used by customers (with unique 6-digit customerID s)

Define when to use hashmap and when to use treemap, How do you decide when ...

How do you decide when to use HashMap and when to use TreeMap? When we want to perform deletion, insertion and locate elements in a Map then HashMap is used. Whereas TreeMa

Programming Excercise, I have to Create a program that determine the shippi...

I have to Create a program that determine the shipping cost for an order based on he following chart: From To Price $0.00 $19.99 $2.95 $20.00 $49.99 $3.95

Difference between java mail and jms queue, JMS is the ideal high-performan...

JMS is the ideal high-performance messaging stage for intra business messaging, with full programmatic control over quality of service and delivery options. JavaMail gives lowes

What is a framework, A framework is made up of the set of classes which per...

A framework is made up of the set of classes which permit us to use a library in a best possible way for a particular requirement.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd