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

Explain arithmetic promotion and binary operations, Explain Arithmetic Prom...

Explain Arithmetic Promotion and Binary Operations? An int divided through an int is an int, and a double divided by a double is a double, but what about an int divided by a do

Overloading method, QUESTION 3: Overloaded methods Write the overloaded me...

QUESTION 3: Overloaded methods Write the overloaded method named average () for each of the following problems: a) The first method receives THREE (3) integer values and returns

Loosely coupled soa, Loosely coupled SOA SOA gives in loosely coupled ...

Loosely coupled SOA SOA gives in loosely coupled application elements, in which message is not necessarily tied to a particular database. Loose coupling actives enterprises to

Is jsp technology extensible?, YES. JSP technology is extensible by the dev...

YES. JSP technology is extensible by the development of custom actions, or tags, which are encapsulated in tag libraries. #question..

Queues, we can insert elements at rear and remove at front bt my question i...

we can insert elements at rear and remove at front bt my question is that how we insert at front in circular queue

Collections, Employee get data from console

Employee get data from console

Dropbox calendar, code in dropbox calendar and loop for feruary leapyear

code in dropbox calendar and loop for feruary leapyear

What are the different scopes for java variables, What are the different sc...

What are the different scopes for Java variables? The scope of a Java variable is explained by the context in which the variable is declared. Therefore a java variable can have

Program, Luminous Jewels - The Polishing Game Byteland county is very famo...

Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum

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