what is variable ?
A variable is a named container that stores a value or data in a computer's memory.These values can change during a program's execution, which is why they are called "variables".
Variables are used to store different types of data, such as numbers (integers, decimals), text (strings).
What is Class ?
A class is the blueprint from which individual objects are created.
In the real world,many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model.
Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles.
what is object ?
Objects are key to understanding object-oriented technology. They all have state and behavior.
Example:In real world,Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes). Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming.
what is method ?
Definition: Two of the components of a method declaration comprise the method signature—the method's name and the parameter types.
The signature of the method declared above is:
calculateAnswer(double, int, double, double)
Naming a Method :
method names should be a verb in lowercase or a multi-word name that begins with a verb in lowercase, followed by adjectives, nouns, etc. In multi-word names, the first letter of each of the second and following words should be capitalized. Here are some examples:
run
runFast
getBackground
getFinalData
compareTo
setX
isEmpty
Typically, a method has a unique name within its class. However, a method might have the same name as other methods due to method overloading.
what is Arguments and parameters ?
A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters. Parameters are the Names. Arguments are the Values
Parameter is the variable in the declaration of the function.
Argument is the actual value of this variable that gets passed to the function.
Parameters refers to the list of variables in a method declaration.
Arguments are the actual values that are passed in when the method is invoked.
When you invoke a method, the arguments used must match the declaration's parameters in type and order.
What is return datatype ?
A method returns to the code that invoked it when it
- completes all the statements in the method,
- reaches a return statement, or
- throws an exception (covered later), Any method declared void doesn't return a value. It does not need to contain a return statement. If you try to return a value from a method that is declared void, you will get a compiler error. The data type of the return value must match the method's declared return type.
References:https://docs.oracle.com/javase/tutorial/java/concepts/class.html
References:https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter
Top comments (0)