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

What is spring, Spring is an open source framework created to address the d...

Spring is an open source framework created to address the difficulty of enterprise application development. One of the chief benefits of the Spring framework is its layered archite

What is portableremoteobject.narrow() method , What is PortableRemoteObject...

What is PortableRemoteObject.narrow() method and what is used for?                Ans) Java RMI-IIOP gives a mechanism to narrow the the Object you have received from from your

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

code in dropbox calendar and loop for feruary leapyear

What is heuristic, What is heuristic? Heuristic is a procedure which co...

What is heuristic? Heuristic is a procedure which commonly, but not always, works or that provides nearly the right answer.

Explain exception classes, OOPS with Java 1. Explain any five buzz word...

OOPS with Java 1. Explain any five buzz words in Java. 2. Explain exception classes and also explain common exceptions in java. 3. Explain primitive and abstract data typ

Java program to do the following operations:, Read information of n student...

Read information of n students. The class name should be kkhsou with the member variable name, rollno, center_code and percentage in last examestion.Display the students data whose

String, solve the string public int expression("10+20+30")

solve the string public int expression("10+20+30")

Java 2 micro edition - programming for mobile phones, You must design, code...

You must design, code and demonstrate a J2ME program (a program capable of running on mobile telephones) according to the specification given in the next section.  The overall cour

Sum of six digits, How do I write a java program that enters a six digit nu...

How do I write a java program that enters a six digit number and takes the sum of the six digits?

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