answersLogoWhite

0

Instead of using public variables, people have a tendency to use it as private variable (They call it encapsulate) and only allow other access these variable via getters and setters. For example:

class Calculator {

private int a;

public int getA(){

return a;

}

public void setA(int a){

this.a = a;

}

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is function in java terminology?

In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.


Is main a predefined function in java?

No. It is a user defined function which the person who is creating the java class has to code by himself.


In java public static voidmain function denotes what?

Java's main function denotes the entry point into the execution of your program.


What are functions in JAVA?

for loop function


Who invoke main function in java?

The Java Runtime Environment invokes main methods.


What is importe mean?

import is a function in java that is used to import data types or values or any functions within a specific class.


What is the difference between method and function in java?

A function is a piece of code that can be reused by calling its name while a method is a function that is associated with a class. In Java, functions are usually referred to as static methods.


What is subroutine in java?

Subroutine mean what (in java)?


What is a method in Java?

A Java method is a sequence of statements. It is comparable to a function, subroutine, or procedure in other languages.


Can we execute java program without main function?

no


What does the warning Illegal Argument Exception mean in Java language?

The warning Illegal Argument Exception in Java means that one has attempted to pass a wrong type of argument for a function. For example, we have a function that calculates a sum of two numbers and feed it a text string, which results in Illegal Argument Exception.


What does Systemout mean in java?

System.out refers to the Java console.